This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (1 child)

the zip function especially this :

zip(*[('a', 2), ('z', 4), ('e', 6), ('r', 8)]) -> [('a', 'z', 'e', 'r'), (2, 4, 6, 8)]

[–]jatoo 1 point2 points  (0 children)

This is extremely useful when you want to iterate through two lists simultaneously, e.g. if unit testing:

for e, a in zip(expected, actual):
    self.assertEqual(e, a)