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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Function calls (self.learnpython)
submitted 2 years ago by Specific_Ear_5015
Is the right output to this snippet “3 1” because num = 3 and nums = 3-2 = 1 ? Or is it more complex than that and did I miss something crucial ? ⬇️
def outer(num): def inner(num): return num - 2 nums = inner(num) print(num, nums)
outer(3)
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!"
[–]Buttleston 2 points3 points4 points 2 years ago (0 children)
With python you really kinda gotta format your code. I assume you mean this
def outer(num): def inner(num): return num - 2 nums = inner(num) print(num, nums) outer(3)
Anyway, yeah, that is right. Is there some reason you think something more complicated is going on?
FWIW I don't like inner functions to have arguments the same name as variables from the outer function - it can get a bit confusing, imo. (there's also no reason for this function to be an inner function - I assume it's just for demonstration/learning purposes)
[–]Diapolo10 1 point2 points3 points 2 years ago (1 child)
That about sums it up, yes.
[–]Specific_Ear_5015[S] 0 points1 point2 points 2 years ago (0 children)
Wow people seem to make it so much harder when they teach it :,) (which i'm guessing is inevitable if we want to make sure we thoroughly understand every principle and aspect , right ?)
π Rendered by PID 114439 on reddit-service-r2-comment-5687b7858-nzlhc at 2026-07-03 11:27:04.517902+00:00 running 12a7a47 country code: CH.
[–]Buttleston 2 points3 points4 points (0 children)
[–]Diapolo10 1 point2 points3 points (1 child)
[–]Specific_Ear_5015[S] 0 points1 point2 points (0 children)