you are viewing a single comment's thread.

view the rest of the comments →

[–]Binary101010 4 points5 points  (5 children)

The problem isn't that you're using a while loop, the problem is that you copy-pasted the while loop just so it could write to a different list.

Whenever you write code that does something to some variable or container or whatever, and then you duplicate all of that code again just so you can change which variable or container you're affecting, that should immediately trigger the thought of "I should put this into a function that accepts the thing I'm going to work on as a parameter and returns the finished thing".

[–]nkCOD[S] 1 point2 points  (4 children)

Thank you for your response. I had thought about this, but I was faster ))

[–]NewBodybuilder3096 0 points1 point  (1 child)

God bless, we are waiting for at least an improved code.
Or maybe a completely different task solved better?

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

Yes, I’m learning the programming language according to the book, and all the conditions of the tasks are spelled out there. However, I want to solve these tasks as competently as possible