[Tutor] print as columns

Mike Serpa onav@yahoo.com
Tue, 17 Jul 2001 15:02:54 -0700 (PDT)


> > 
> > Couldn't we shorten this to:
> > n=len(max(lists))   
> > 
> > It seems that everything I figure out how to do is already in a
> module
> > somewhere.  Question for expert Python coders (or any lang.) Do you
> > ever  get to the stage where you don't have to constantly look
> things
> > up in the lang docs?
> 
> Actually, none of these work.  The max of a list of lists is to find
> out
> which list is greater, by component, not the longer.
> 
> >>> a = [1, 2, 3]
> >>> b = [3, 4, 5, 6]
> >>> max(a, b)
> [3, 4, 5, 6]
> >>> c = [7, 8, 9]
> >>> max(b, c)
> [7, 8, 9]
> 
> You probably want to use: reduce(max, map(len, seq_o_lists))
> 
> >>> reduce(max, map(len, (a, b, c)))
> 4
> 

Okay, yeah I see how max() works now.

But we don't need reduce, do we?  Just:

max(map(len, (a, b, c)))

right?  Or am I missing something?


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/