0
While Loops
i = 0 while 1 == 1: i += 1 print(i) if i >= 5: break print("Almost Done.") print("Finish!") Why this code DISPLAY 1,2,3,4,5 but i = 0 while 1 == 1: Print(I) i += 1 if i >= 5: break print("Almost Done.") print("Finish!") DISPLAY 0,1,2,3,4
2 odpowiedzi
+ 2
BlackChain couse you change place for
I+=1
And
Print(i)
+ 1
The code is producing what it reads.
In your second code, you are asking it to print the output before i+=1, so it starts from 0