Python traverse two lists at the same time

Python traverse two lists at the same time

list1 = ['a', 'b', 'c', 'd']
list2 = ['apple', 'boy', 'cat', 'dog']
for x, y in zip (list1, list2):
  print (x, y)
Note: the two lists are the same length

 

 
 

Guess you like

Origin www.cnblogs.com/Sakurar/p/12723903.html