+ 1

When i changed i=i+1 to i+=i,the output also changed into 1,2,3,4,finished....previously output was 1,2,3,4,5,finished.why?

i = 1 while i <=5: print(i) i += i print("Finished!")

15th Sep 2020, 12:25 PM
Muhtasinul
Muhtasinul - avatar
2 odpowiedzi
+ 4
i=i+1 is same as i+=1 And different to i+=i which is i+=i the output was 1,2,4 ?
15th Sep 2020, 12:28 PM
Oma Falk
Oma Falk - avatar
0
Yep
15th Sep 2020, 12:31 PM
Muhtasinul
Muhtasinul - avatar