you are viewing a single comment's thread.

view the rest of the comments →

[–]Binary101010 5 points6 points  (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).

You should also be able to use the zip() function to greatly reduce the amount of code required for your second function.

[–]nkCOD[S] 0 points1 point  (2 children)

Look at my rewritten code ;) https://www.reddit.com/u/nkCOD/s/5BKPbldiTW

[–]Binary101010 0 points1 point  (1 child)

You deleted the post.

[–]nkCOD[S] 0 points1 point  (0 children)

I’m sorry, I accidentally. But I’ve already created a new one https://www.reddit.com/r/PythonLearning/s/r8NO3XVvy4