Enumerate two python lists simultaneously?

前端 未结 6 790
既然无缘
既然无缘 2020-12-13 03:42

How do I enumerate two lists of equal length simultaneously? I am sure there must be a more pythonic way to do the following:

for index, value1 in enumerate(         


        
6条回答
  •  既然无缘
    2020-12-13 04:02

    for i, (x, y) in enumerate(zip(data1, data2)):
    

    In Python 2.x, you might want to use itertools.izip instead of zip, esp. for very long lists.

提交回复
热议问题