0
In Python 3 Why the output is 0 but not 1 when I have this?
i=0 while 1==1: print(i) i+=1 break
2 Respuestas
+ 1
1==1 is the same as just using True
while True: creates an infinite loop if no end condition within the loop (break)
i is equal to 0 when the loop is entered
i is then printed which outputs 0
Then 1 is added to i and the new value is set back to the variable i (i +=1)
Then the loop is immediately exited with break and no further values are output.
0
@ChaoticDawg Thanks