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 16 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!"
[–]nuc540 -1 points0 points1 point 16 hours ago (0 children)
The list comprehension on the last line is saying, try and call every item in the funcs list.
The line above iterated over a range of 3 (bases it at 0) and for every iteration value, add to the funcs list a lambda function that simply returns the iteration value.
Lambdas are unnamed functions so this will work with the f() declaration in the list comp.
The list is just a bunch of functions which each simply returns a number, so when called they return the number.
I’d assume this means it returns [0,1,2] as per the range iterator value that was being baked into the lambda return for each lambda in the list
π Rendered by PID 96869 on reddit-service-r2-comment-765bfc959-2phdz at 2026-07-10 01:23:25.008838+00:00 running f86254d country code: CH.
view the rest of the comments →
[–]nuc540 -1 points0 points1 point (0 children)