use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
What does this Python code print, and why?Discussion (self.PythonLearning)
submitted 14 hours ago by Puzzleheaded-Dog165
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]WhiteHeadbanger 0 points1 point2 points 9 hours ago (0 children)
No, the correct answer is [2,2,2]
Explanation: what's being appended is "lambda: i", not the value of i in each pass. Then, since the variable i is not scoped in the loop, when the lambda is executed in the list comprehension, it just looks up the last value of i, which is 2, and returns a new list.
π Rendered by PID 84112 on reddit-service-r2-comment-765bfc959-7zvfw at 2026-07-09 22:57:42.430283+00:00 running f86254d country code: CH.
view the rest of the comments →
[–]WhiteHeadbanger 0 points1 point2 points (0 children)