Ask Your Question

Revision history [back]

If you want to pair up the elements of two lists, you can use zip (it's like a zipper):

sage: [v[:i] for v,i in zip(A,B)]
[[3, 2, 1], [4, 3, -1, 0, -1]]

If you want to pair up the elements of two lists, lists (instead of taking all combinations as you were), you can use zip (it's like a zipper):

sage: [v[:i] for v,i in zip(A,B)]
[[3, 2, 1], [4, 3, -1, 0, -1]]