[Tutor] Else vs. Continue
Rafael Knuth
rafael.knuth at gmail.com
Sun Nov 24 22:32:20 CET 2013
Hej there,
I stumbled upon the "continue" statement and to me it looks like it
does exactly the same as else. I tested both else and continue in a
little program and I don't see any differences between both. Is my
assumption correct or wrong? If the latter is the case: Can you give
me examples of continue usage that couldn't be done with else?
Here's my code sample I mentioned above:
for num in range(2,10):
if num % 2 == 0:
print("Found an even number", num)
continue
print("Found a number", num)
Same program with else:
for num in range(2,10):
if num % 2 == 0:
print("Found an even number", num)
else:
print("Found a number", num)
Thanks in advance!
All the best,
Raf
More information about the Tutor
mailing list