How do I replace 3 with "skipping"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
15th Jan 2021, 11:22 AM
Vivian Anoemuah
Vivian Anoemuah - avatar
3 Answers
+ 3
i=1 while i<=5: if i==3: print("skipping") i+=1 # <---- Increment continue print(i) i+=1 # The "if" statement or condition should come first before the "print(i)" so that the program will check first if i is 3, if i is 3 then it will print "skipping" then increment (which you forgot), then continu to next iteration. Otherwise, the program will print the number.
15th Jan 2021, 11:31 AM
noteve
noteve - avatar
+ 3
Maybe like this! i=0 while i<5: i+=1 if i==3: print("skipping") continue print(i)
15th Jan 2021, 11:27 AM
Abhay
Abhay - avatar
0
print(i) i+=1 if i==3: print("skipping") i+=1 continue
15th Jan 2021, 11:27 AM
Иван Чикyнов
Иван Чикyнов - avatar