do you master list comprehensions?

Timothy Babytch tim at zeos.net
Tue Dec 14 05:49:59 EST 2004


Will Stuyvesant wrote:

>>>>data = [['foo','bar','baz'],['my','your'],['holy','grail']]

sum(data, [])

['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']

The second parameter passed to sum is just to overrride default
initial value "zero".

-- 
Timothy Babytch



More information about the Python-list mailing list