List Comprehension Syntax

Aahz aahz at pythoncraft.com
Thu Jul 22 16:09:39 CEST 2004


In article <HI7Ic.17372$1Z7.12975 at newssvr27.news.prodigy.com>,
Moosebumps <crap at crap.crap> wrote:
>
>>>> result = [x for x in range(10) if x % 2 == 0 if x % 3 == 0]
>>>> result
>[0, 6]
>>>> result = [ x*y for x in range(10) if x%2 == 0 for y in range(10) if y %
>3 == 0]
>>>> result
>[0, 0, 0, 0, 0, 6, 12, 18, 0, 12, 24, 36, 0, 18, 36, 54, 0, 24, 48, 72]
>
>Just curious -- anyone care to tell me how they would format the above?  (or
>maybe you wouldn't write it all)

Wouldn't use either.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Barbara Boxer speaks for me:
http://buffaloreport.com/2004/040713.boxer.marriage.html



More information about the Python-list mailing list