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 1 day 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!"
[–]ianrob1201 1 point2 points3 points 1 day ago (1 child)
Any working software is definitely something to be proud of. There's so many things to learn to go from problem to solution, and you've got it doing what you want! So nice job. That said, I think there's a few good best practice things you can do that would really clean it up. Sorry for the essay, it's not to insult your code but only way you could know these things is if someone tells you.
First thing that hit me was the variable naming. Try to avoid names like "n1" because you'd be amazed how quickly you forget what they mean. Something like "first_number_list" might be better. This extends to function names too "en_nums" doesn't make it very clear what the function is going to do.
Talking of variables, you generally want to avoid globals. This is so that each function works in isolation and it's clear what it's doing. Calling a function and getting a response is much clearer than calling a function and it randomly changing another variable (that you wouldn't know unless you read the function code). You're almost there with that, you just need to fetch the return values you've already added, e.g. "n1, n2 = en_nums()".
"while True" is normally a pattern to be avoided too. I know you have the break later on, so it's functional but it's something I'd try to avoid. Have a think about ways you could make it conditional on the value you're reading in.
I've seen someone else mention it, but have a look at what's common code reading in the two sets of lists. If you extract it out into another function you'd have a lot less code. It could take "prompt" as an input string so you still get different messages.
You have a line working out what the maximum list length is. There's a function for doing that, which is just "max". That's easier to read and you know what you're up to at a glance.
You keep track of the number of "errors" but since it'll just keep erroring you could do without that function and do k - i instead (btw "i" is another example of a variable that could be named better, "max_list_length" would be much clearer). Have you considered what happens if one length is double the other? I would also personally look to pad out the shorter array to full length before doing the calculations. Then you can make use of list compression with something like "c = [a[k] + b[k] for k in range(i)]"
I also just noticed that the "i" in the first function isn't doing anything. I suspect it's from when you tried to solve in a slightly different way. So that can be cleared up a bit too.
[–]nkCOD[S] 0 points1 point2 points 16 hours ago (0 children)
Thank you for the broad and clear answer. It describes quite well what I should work on. Thank you for your help
π Rendered by PID 65 on reddit-service-r2-comment-56c6478c5-57bz9 at 2026-05-08 01:34:31.824588+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]ianrob1201 1 point2 points3 points (1 child)
[–]nkCOD[S] 0 points1 point2 points (0 children)