Your while
loop does not do the same thing as your for
loop; the for
loop starts at 1 and always increments i
.
Move the i += 1
before the even test:
i = 0
while(i < 10):
i += 1
if i % 2 == 0:
continue
print i
because 0 % 2 == 0
is True
, so you always continue, skipping the i += 1
and print i
statements.
2
solved Python continue with while