• + 4 comments

    "list comprehension" is in the form : [ A B C]

    Part A defines the element(s) put into the new list. Part B is a set of <"for" element(s) "in" collection> statements. Part C contains optional "if" statements that filter each collection element from consideration. In this case it looks like...

    A 	   B 				C
    [marks   for name, marks in marksheet] there is no C 
    [new2  for new1, new2 in parent] 
    

    The tricky part is between "for" and "in" of Part B.

    B slices the parents child lists horizontaly into two new lists (name and marks), iteratively assigning name=marksheet [0] and marks=marksheet [1]

    Part A says "im only interested in keeping the marks list." We throw away the new list called "name."

    I suppose if the childlists each had N elements you could say, "for new1, new2, new3,,,newN in ParentList" and be able to manipulate N new lists in your part A.

    Hope helpful