[Tutor] Continue Statement

Alan Gauld alan.gauld at btinternet.com
Mon Dec 16 18:04:54 CET 2013


On 16/12/13 14:12, Alina Campana wrote:

Please use plain text for emails. Rich text tends to mess up the 
indentation as you can see below. However via the web interface I was 
able to see what you did so...


> i = 0
> while (i < 10):
> if i == 5:
> continue
> print i
> i+=1
>
> Instead it seems to freeze after 4. The shell input symbol is blinking.

The continue jumps back to the start of the loop. But you have not
at that point incremented i so it is still 5, and remains 5 forever.
If you move the i += 1 line to the top of the loop it will work as you 
expect except you will print 1-10 instead of 0-9.

> Okay thank you people, I go now learn better english ^^

Your English is fine, no problem.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list