[Tutor] Iterating over multiple lists- options

Tony Cappellini tony at tcapp.com
Tue Feb 8 07:12:08 CET 2005

map(None, North, South, East West) does exactly what you want:
   >>> North=['Bill', 'Bob', 'Sue', 'Mary']
   >>> South=['Tim', 'Tom', 'Jim', 'John', 'Carl', 'Evan', 'Rich']
   >>> map(None, North, South)
[('Bill', 'Tim'), ('Bob', 'Tom'), ('Sue', 'Jim'), ('Mary', 'John'), (None, 
'Carl'), (None, 'Evan'),
(None, 'Rich')]

 > That being, both of these functions can truncate the data, depending on
 > certain conditions

 >>I don't think that is true for map(); what conditions are you thinking of?
Well, I've tried duplicating what I was seeing last night when I posted the 
message, and it's not happening the same now.
Maybe I was up too later working on this problem...

What I *thought* I was seeing was map() would return a list of a certain 
length when I called it like this map(None, North, South)
and returned a list of a different length when I called it like this 
map(None, South, North)

However, trying that now basically returns the a list that appears to be 
the same length, for both calls.

I think this will work after all. I'll add it to my program .

Thanks for your quick replies

More information about the Tutor mailing list