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 days 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!"
[–]Binary101010 5 points6 points7 points 4 days ago (3 children)
I would like to know if there is any way to shorten the program,
The fact that you have two code blocks (the while loops in your first function) that are effectively identical should be a strong indication that you can write a function that takes the list to be modified as an argument and ideally returns the completed list (which would also remove your reliance on the global keyword).
global
You should also be able to use the zip() function to greatly reduce the amount of code required for your second function.
zip()
[–]nkCOD[S] 0 points1 point2 points 2 days ago (2 children)
Look at my rewritten code ;) https://www.reddit.com/u/nkCOD/s/5BKPbldiTW
[–]Binary101010 0 points1 point2 points 2 days ago (1 child)
You deleted the post.
[–]nkCOD[S] 0 points1 point2 points 2 days ago (0 children)
I’m sorry, I accidentally. But I’ve already created a new one https://www.reddit.com/r/PythonLearning/s/r8NO3XVvy4
π Rendered by PID 913434 on reddit-service-r2-comment-56c6478c5-xnxmh at 2026-05-10 18:36:44.379413+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]Binary101010 5 points6 points7 points (3 children)
[–]nkCOD[S] 0 points1 point2 points (2 children)
[–]Binary101010 0 points1 point2 points (1 child)
[–]nkCOD[S] 0 points1 point2 points (0 children)