simultaneous iteration of lists

Dave Harrison dlharris at mail.usyd.edu.au
Wed Jul 17 12:24:46 EDT 2002


Evenin' all,

Looking for advice on simultaneous iteration of two lists.

I have two lists of equal length (guaranteed) , and I want to iterated over both at the same time without having to write myself a little counter thingo cause it seems slightly unpythonic.
Both lists are generated by seperate functions which get their input from seperate sources so using a dictionary isnt an option either.

The syntax that is in the back of my brain looks something like 

for i,j in list1,list2:
	print i
	print j

But this gives me the error :

ValueError: unpack list of wrong size

Anyone be of help ?

Thanks
Dave





More information about the Python-list mailing list