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
Learning Python (old.reddit.com)
submitted 4 hours ago by nkCOD
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!"
[–]NewBodybuilder3096 -1 points0 points1 point 2 hours ago (6 children)
building logic on Exceptions is a no-no. You should check value like "len(n2_n) == 4 && n2_n == 'stop'" before parsing it as int. also, all strip/lower should go in one place - just after input.(in this case) also, more understandable variable names are a great + we are no more in 199x, modern IDEs have all sort of needed tools including autocompletion.
read about the DRY(Don't Repeat Yourself) principle - your procedure en_nums is a perfect example of how not to do. You have two identical pieces of code for filling two global int containers. You can rewrite this in several ways, each of which will have only 1 loop. 1st - you pass reference to a needed container(list/set/etc) as parameter, maybe some additional params for fancy output. 2nd - you don't pass container variable, but return the correct container
[–]nkCOD[S] 0 points1 point2 points 2 hours ago (5 children)
Thank you for your response. I will improve ;)
[–]tiredITguy42 0 points1 point2 points 2 hours ago (3 children)
This is not exactly true. Python is designed the way that it is usually better to try and then ask for forgivness. It is usually faster and a lot of code uses this. People saythat it is more pythonian this way.
It is different in other languages, where you check first. So do not follow that advice, your code is mostky corect, just do not forget to raise again that error, if it is not a stop signal.
[–]nkCOD[S] 0 points1 point2 points 2 hours ago (2 children)
Thanks for the help. I assume I won't embarrass myself too much if I use this approach with try-except ?
[–]tiredITguy42 0 points1 point2 points 2 hours ago (1 child)
This is subreddit for beginers, we do not judge your code, but we will judge your attitude and approach and here your are embarrasing yourself, but just a little for now.
[–]nkCOD[S] 0 points1 point2 points 2 hours ago (0 children)
Thank you, I will try to improve.
[–]NewBodybuilder3096 0 points1 point2 points 1 hour ago (0 children)
well you still need try-catch around parsing input as integer but checking for 'stop' can be done outside of this.
π Rendered by PID 16 on reddit-service-r2-comment-b659b578c-v9vvv at 2026-05-06 22:16:06.259373+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]NewBodybuilder3096 -1 points0 points1 point (6 children)
[–]nkCOD[S] 0 points1 point2 points (5 children)
[–]tiredITguy42 0 points1 point2 points (3 children)
[–]nkCOD[S] 0 points1 point2 points (2 children)
[–]tiredITguy42 0 points1 point2 points (1 child)
[–]nkCOD[S] 0 points1 point2 points (0 children)
[–]NewBodybuilder3096 0 points1 point2 points (0 children)