do you master list comprehensions?

Luis M. Gonzalez luismgz at gmail.com
Tue Dec 14 02:44:33 CET 2004


I guess the simplest way to do it is like this:

>>> data = [['foo','bar','baz'],['my','your'],['holy','grail']]
>>> result=[w for d in data for w in d]
>>> result
['foo', 'bar', 'baz', 'my', 'your', 'holy', 'grail']
>>>




More information about the Python-list mailing list