0
Why does my python loop only execute once?
7 Answers
+ 3
If you have a loop in your code
... and it executes once successfully (without causing an exception)
... and you were expecting it to run more than once
... and there is no other exit within the loop, such as a break statement
then the loop condition must be wrong or else a factor that updates the condition is wrong.
If it is a while loop, then check the conditional. A while loop executes while the conditional is true.
If it is a for loop, then check the start value, the end value, and the step increment.
+ 3
onifade David ,
can you please link your code here?
+ 2
there is no loop...
+ 2
Example please
0
Probably because the condition for your loop jas been meet
0
If you are using a for loop, you have to insert a value in the brackets;
For example, for i in range(5):
print("Hello World.")
But if you want it to loop an infinite number of times, use a while loop.
0
Can you send your code