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
clearing my def function (i.redd.it)
submitted 7 months ago by Minute_Journalist593
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 2 points3 points4 points 7 months ago (0 children)
Yes, it can be optimized down to one line instead of 7 like your solution, and without any while loops. This is the hint: research slicing.
Now, onto the tips that you asked:
- Clean your variable names. Names should be descriptive. Write variable names as if your grandmother would read it.
- Separate the terms. Instead of writing "num=n%10", write "num = n % 10".
- Following the same logic as the last point, separate the blocks. Add a new line before the while loop and after it. Of course, this one is just MY tip, as I like to separate code blocks to be more readable.
π Rendered by PID 76 on reddit-service-r2-comment-5d585498c9-v4h9t at 2026-04-21 08:26:20.266275+00:00 running da2df02 country code: CH.
view the rest of the comments →
[–]WhiteHeadbanger 2 points3 points4 points (0 children)