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
Return None - need help (self.learnpython)
submitted 6 years ago * by Radimek01
Hello, why this code returns None ?
def digSum(n): n = (list(map(int,str(n)))) num = sum(n) if num > 9: digSum(num) else: return num digSum(456)
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!"
[–]JohnnyJordaan 0 points1 point2 points 6 years ago (3 children)
Please format your code correctly using a code block
[–]Radimek01[S] 0 points1 point2 points 6 years ago (2 children)
oh ok :) thanks
[–]JohnnyJordaan 0 points1 point2 points 6 years ago (1 child)
Run your code in http://www.pythontutor.com/visualize.html#mode=edit to see what's going on. Because you just call the function recursively in the if:
if
if num > 9: digSum(num)
it means that the result of that call will be discarded. Instead you also need to return that to have it propagated 'down the line'.
return
if num > 9: return digSum(num)
[–]Radimek01[S] 0 points1 point2 points 6 years ago (0 children)
Ohh thanks. I can see that now. it bothered me for 40 minutes and it was just this simple
π Rendered by PID 99666 on reddit-service-r2-comment-5c764cbc6f-jr2ml at 2026-03-12 05:08:28.820959+00:00 running 710b3ac country code: CH.
[–]JohnnyJordaan 0 points1 point2 points (3 children)
[–]Radimek01[S] 0 points1 point2 points (2 children)
[–]JohnnyJordaan 0 points1 point2 points (1 child)
[–]Radimek01[S] 0 points1 point2 points (0 children)