How to keep list structure

Something is still going wrong in my list structure to get my script to dimension correctly. However found this python code that solves all that mess above.

Not sure what this error is though and its still not quite right after going through the Element.CurtainGridline