enumerate() and zip() : zip « Buildin Function « Python Tutorial






albums = ['q', 'w', 'e']

for i, album in enumerate(albums):
     print i, album

fn = ['A', 'B', 'C']
ln = ['a', 'b', 'c']

for i, j in zip(fn, ln):
     print ('%s %s' % (i,j)).title()








13.49.zip
13.49.1.zip() zips together the sequences, returning a list of tuples:
13.49.2.Use zip function in for loop
13.49.3.zip() stops when the shortest sequence is "used up" for different lengths
13.49.4.enumerate() and zip()
13.49.5.zip to a dictionary