+ 1
How do I replace 3 with "skipping"?
3 Respuestas
+ 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.
+ 3
Maybe like this!
i=0
while i<5:
i+=1
if i==3:
print("skipping")
continue
print(i)
0
print(i)
i+=1
if i==3:
print("skipping")
i+=1
continue