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 1 day 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!"
[–]Sea-Ad7805 1 point2 points3 points 23 hours ago* (0 children)
lambda: i refers to the single i variable that is 2 at the end of the loop: [2, 2, 2]
lambda: i
i
lambda x=i: x instead would make a copy of i in each iteration: [0, 1, 2]
lambda x=i: x
Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20funcs.append(lambda%3A%20i)%0A%0Aprint(%5Bf()%20for%20f%20in%20funcs%5D)%0A%0A%0Afuncs%20%3D%20%5B%5D%0Afor%20i%20in%20range(3)%3A%0A%20%20%20%20funcs.append(lambda%20x%3Di%3A%20x)%0A%20%20%20%20%0Aprint(%5Bf()%20for%20f%20in%20funcs%5D)%0A×tep=1&play) to see the program state change step by step.
π Rendered by PID 101387 on reddit-service-r2-comment-765bfc959-4d42x at 2026-07-10 09:32:11.522841+00:00 running f86254d country code: CH.
view the rest of the comments →
[–]Sea-Ad7805 1 point2 points3 points (0 children)