A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/109471.html below:

list comprehensions whats happening here

list comprehensions whats happening herezzzzz zzizz_ at notmail.com
Fri Apr 13 06:04:39 EDT 2001
While trying to remember the correct syntax for list comprehensions I
stumbled upon the following results, can anyone enlighten me as to
what is going on here?

>>> [[i,j] for i in range(3), for j in range(3)]
[[[0, 1, 2], 0], [[0, 1, 2], 1], [[0, 1, 2], 2]]

>>> [[i,j] for i in range(3), for j in range(3),]
[[[0, 1, 2], [0, 1, 2]]]

Here I finally got it right:

>>> [[i,j] for i in range(3) for j in range(3)]
[[0,0],[0,1],[0,2],[1,0],[1,1],[1,2],[2,0],[2,1],[2,2]]



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4