0

How can it be infinite if there stayed while 1 == 1: Because after first time "i" would be 2 and it's not any more while true: ?

i = 0 while 1==1: print(i) i = i + 1 if i >= 5: print("Breaking") break print("Finished") I understand, that it continues 4 time til it breaks. But the meaning of 1 == 1 is not clear. Thanks.

5th Nov 2018, 12:52 PM
Benzema
Benzema - avatar
4 Answers
+ 1
1 == 1 means that if one is one ore the same if you mean that
5th Nov 2018, 1:21 PM
Mbrustler
Mbrustler - avatar
+ 1
You have to write i==1 instead of 1==1. 1 is always equal to 1😂 P.S. there would be no output
5th Nov 2018, 2:36 PM
Roneel
Roneel - avatar
+ 1
Yep, 0 is the value of i at the beginning. On every loop iteration, it increases 1(or other) Only while without condition is not following syntax of while loop. i==1 or other condition should be there (and to be checked on every iteration)
5th Nov 2018, 5:13 PM
Roneel
Roneel - avatar
0
I know "while" will continue until a break. So why we don't just write "While" without 1== 1 or i == 1 ? And what's the meaning of i = 0 Does it mean, that 0 is the value of i at the begin?
5th Nov 2018, 3:19 PM
Benzema
Benzema - avatar