Nested List Comprehension

James T. Dennis jadestar at
Sun Jul 15 15:50:12 EDT 2001

 This is not a question but merely a comment from a 
 newbie.   I'm reading Beazley's 2nd Ed. "Python Essential
 Reference" and playing with things therein and I thought
 "list comprehension, what a quick way to make a multiplication 

 multtab = [ [ x*y for x in range(13) ] for y in range(13) ]

 ... though I was surpirsed that I got the syntax correct
 on the first try.  (It still looks wrong, somehow but 
 [ x*y [x for x in range(13)] [y for y in range(13) ] ] looks
 even more wrong).

More information about the Python-list mailing list