Use zip function in for loop : zip « Buildin Function « Python Tutorial






names = ['A', 'B', 'C', 'D'] 
ages = [12, 45, 32, 102] 

for name, age in zip(names, ages): 
    print name, 'is', age, 'years old'








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