Enumerate two python lists simultaneously?

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(data1):
    print index, value1 + data2[index]

I want to use the index and data1[index] and data2[index] inside the for loop.


Use zip:

for index, (value1, value2) in enumerate(zip(data1, data2)):
    print index, value1 + value2

Note that zip runs only up to the shorter of the two lists(not a problem for equal length lists), but, in case of unequal length lists if you want to traverse whole list then use itertools.izip_longest

Need Your Help

How can I increase text size of android chronometer?

android android-layout android-textview

I have created chronometer programatically.But i don't know how to increase size of chronometer text.following is my code.I have set the initial value 00:00 but this text looking small i want to in...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.