infinite while loop

zoe_matrullo (2070 points)
4 8 12
asked Oct 21, 2021 in Programming in Python by zoe_matrullo (2,070 points)
recategorized Nov 1, 2021 by andrea.sterbini
Hi everybody

I'm trying to complete the first optional homework and my code includes a while loop. The issue is that this specific part prevents my code from working since the loop doesn't stop running. Has anyone any advice on how to solve this problem?

3 Answers

Best answer
gio0628sato (960 points)
2 4 9
answered Oct 21, 2021 by gio0628sato (960 points)
selected Oct 21, 2021 by zoe_matrullo
Maybe you can use the break statement???
leonardo_13 (1420 points)
6 11 16
commented Oct 23, 2021 by leonardo_13 (1,420 points)
That's probably the best solution.
Lorenzo_Pellegrino (690 points)
2 2 8
commented Oct 25, 2021 by Lorenzo_Pellegrino (690 points)
Or you can check the loop conditions and verify if at some point they get statisfied, if not, there will be the endless loop
andrea.sterbini (168150 points)
488 897 1728
answered Oct 21, 2021 by andrea.sterbini (168,150 points)
Have you checked that the while condition becomes False eventually?
gabrimat (5520 points)
2 2 23
answered Oct 21, 2021 by gabrimat (5,520 points)
Maybe if you are using a while loop with a counter (using while because you are checking multiple conditions) check that you have actually added the counter increase assignment. Maybe with more information I could understand better your situation.