0
What is the difference between two result?
The example is i = 0 while 1==1: print(i) i = i + 1 if i >= 5: print("Breaking") break print("Finished") And my answer is 0 Finished 1 Finished 2 Finished 3 Finished 4 Breaking but, the solution is >>> 0 1 2 3 4 Breaking Finished >>> what is the difference those answers?? please save me lol :(
5 Answers
+ 2
Indentation of the last print statement should be a problem
+ 1
đđ˘đ˘đđ¨ đđĄđđ˛đđĽ very true. Its while i < 4. What I'm trying to nail home is the principle of indentation and the part it plays in loops.
0
Infinity is right. And its your while loop.
while 1 == 1 is a loop that'll go on forever. Try: while i < 5. The only way it would print finished every iteration is if it was IN the while loop. print('Finished') is fine in the example you gave.