List Comprehension

Colin J. Williams cjw at connection.com
Fri Jul 28 12:34:02 EDT 2000



Is the following, from          
http://www.pythonlabs.com/talks/PythonState_files/v3_document.htm

a misprint? 

     [(x,x**2) for x in
     range(5)]
                         ->
     [(0,0), (1,1), (4,4), (9,9),
     (16,16)]

Should the result not be: [(0, 0), (1, 1), (2, 4) (3, 9), (4, 16)]?

Colin W.



More information about the Python-list mailing list