Monday, December 17, 2012

Python Quicktip: zip()


This is a useful thing I just learned, zip() takes two list as a parameter and then returns a tuple. This is for instance great for iterating over two lists in the same loop.

2 comments:

  1. Also great for iterating over 2 lists simultaneously:

    for a, b in zip(listA, listB):

    ReplyDelete
  2. Excellent,

    used it once in my script. Thanks for sharing. :)

    ReplyDelete