Look closely at your code:
I suspect you wanted this:
To be honest, 30 seconds with the debugger would have shown you exactly what the problem was, and you could have fixed it yourself very easily: pdb — The Python Debugger — Python 3.12.0 documentation
It's worth getting into the habit of always testign your code in the debugger - it is the best tool you have, and can make your whole life far, far easier!
Quote:I am very new to programming. Do you think I can really debug my errors myself?
If you write your own code, you know what it is supposed to do. What the debugger allows you to do is take control of your while it is running and look at variables to see what the hold, to run your code line by line to see where it is going, and to understand what it is actually doing.
Can you do it? Yes, almost certainly. Take the example of your original problem: with the debugger you would have seen that
before you executed this line
and expected it to contain
after - but it didn't, it contained
again! That tells you why it's staying in the loop (because
isn't changing at all) and what line of code was causing that. It's pretty simple to spot the actual problem from looking at that!
Try it: run your original code in the debugger and look at what happens.