iterating over lists

Alex new_name at mit.edu
Sat Jun 2 12:38:41 EDT 2001


Try this:

for x1, x2, x3 in zip(list1, list2, list3: print x1, x2, x3

> If I do:
> 
>      for i in range( 1, len(list1) ):
> 	   print list1[i], list2[i], list3[i]
> 
> I assume the len(list1) call will only be evaluated once.

Yes.

Alex.



More information about the Python-list mailing list