infinite while loop

z
zoe_matrullo (2090 points)
4 8 12
asked Oct 21, 2021 in Programming in Python by zoe_matrullo (2,090 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?
216 views

3 Answers

Best answer
g
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???
l
leonardo_13 (1530 points)
6 13 18
commented Oct 23, 2021 by leonardo_13 (1,530 points)
That's probably the best solution.
Lorenzo_Pellegrino (770 points)
2 4 10
commented Oct 25, 2021 by Lorenzo_Pellegrino (770 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 (172680 points)
511 927 1776
answered Oct 21, 2021 by andrea.sterbini (172,680 points)
Have you checked that the while condition becomes False eventually?
gabrimat (5630 points)
2 2 25
answered Oct 21, 2021 by gabrimat (5,630 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.