[Tutor] List comprehension possible with condition statements?

Jojo Mwebaze jojo.mwebaze at gmail.com
Wed Mar 3 09:31:22 CET 2010


Hi There,

i would like to implement the following in lists

assuming

x = 3
y = 4
z = None

i want to create a dynamic list such that

mylist = [ x , y, z ] ,   if z in not None

if z is None then

mylist = [x,y]

Anyhelp!

cheers

Jojo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100303/a9a9b422/attachment-0001.html>


More information about the Tutor mailing list