+ 1
Code Result
The result of the code three lines under is 1 3 4. But why not 0 1 3 4?? If "i = 0", then why doesn't the result of this code start with 0? i = 0 while True: i += 1 if i == 2: continue if i == 5: break print(i) In for instance the result of this code below also is "i = 0", but this one does start with zero. How? Why??? i = 0 while 1==1: print(i) i += 1 if i >= 5: break Thanks!!!
2 Respuestas
+ 6
The Nanster , this is happening because in the first program, you printed i after increasing its value by 1, on the other hand, in the second code, you first printed i and then did i=i+1
0
code works line by line.
in the top one, the first thing you did was add 1 to i
the bottom one printed i first, then added 1 to it