Unpack items and count them with one step

you can unpack the value returned by enumerate straight into the tuple (your pseudo-code just misses the brackets):

for index, (x, y) in enumerate(zip(X, Y)):
    print(f'{index}, {x}, {y}')

–>

0, [1, 2, 3, 4], [11, 21, 31, 41]
1, [5, 6, 7, 8], [51, 61, 71, 81]
...

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top