- 1
why this code execute different in my python ?
i=0 while 1==1: print(i) i=i+1 if i>=5: print('breaking') break print('End') 0 End 1 End 2 End 3 End 4 Breaking
2 Answers
+ 2
Indentation? If you don't want endless 'Ends' then don't indent that line so it looks to python as if it's part of your 'while'.
In other words, that line should probably be aligned left.
0
once u break, the next code in the loop doesn't execute........that's why 'End' isn't printed