- 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

8th Oct 2016, 1:01 PM
William tirtodipoero
William tirtodipoero - avatar
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.
8th Oct 2016, 2:27 PM
Kirk Schafer
Kirk Schafer - avatar
0
once u break, the next code in the loop doesn't execute........that's why 'End' isn't printed
8th Oct 2016, 1:31 PM
Valentino Ugbala
Valentino Ugbala - avatar