+ 1

i = 0 / while i<5: / i += 1 / if i==3: / print("Skipping 3") continue / print(i). code starts at "1" and prints 5 why?

While loop

27th Apr 2022, 1:01 PM
Israel Ebiti
Israel Ebiti - avatar
2 Réponses
0
Because that's what you code tells it to do. Because i=0 and print(i) are outside the loop
27th Apr 2022, 1:22 PM
Paul K Sadler
Paul K Sadler - avatar
0
You can post a code with the plus sign like this: https://code.sololearn.com/cSZ4MkdJ553X/?ref=app It starts with 1 because you first add 1 to i and then you print i. You print 5 because you say i<5. So with i==4 you entered the loop the last time and it's like before with 1. You first add 1 to I and then you print i.
27th Apr 2022, 2:50 PM
Stefanoo
Stefanoo - avatar