Loop over two or more sequences at the same time
# Loop over two or more sequences at the same time, # the entries can be paired with the zip() function. questions = ['A', 'B', 'C'] answers = ['a', 'b', 'c'] for q, a in zip(questions, answers): print 'What is your %s? It is %s.' % (q, a)
1. | Generator Expressions | ||
2. | Zip a two lists | ||
3. | Read element in a zipped list | ||
4. | Zip three tuples | ||
5. | Difference between zip and map | ||
6. | Zip function demo: returns a list of tuples |