else in list comp
David Eppstein
eppstein at ics.uci.edu
Wed Jan 29 00:36:32 EST 2003
In article <mailman.1043813212.6357.python-list at python.org>,
Cliff Wells <clifford.wells at attbi.com> wrote:
> Given the list:
>
> l = ['mary', 'had', 'a', 'little', None]
>
> it should get mapped to ['mary', 'had', 'a', 'little', '']
[x or '' for x in l]
btw, l is a bad letter to use for a variable name (easy to confuse with
1 or I or even |).
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list