HN user

jppbkm

1 karma
Posts0
Comments1
View on HN
No posts found.

Aww, zip is great!

  for x,y in zip(['a', 'b', 'c'], ['1', '2', '3']):

     print(x + y)

  >>'a1'

  >>'b2'

  >>'c3'
Usually you just use it to group two items you're iterating through that are the same length. You CAN do items of different lengths but then when one gets used up the rest of the other get tossed IIRC. Can use it in list comprehensions as well of course.

Zip was simpler than I thought when I first saw it.