On 16/12/2013 14:12, Alina Campana wrote:
Hello dear tutorlist,
I feel terribly ashamed for my bad english...
Please *DO NOT* apologise for your English, it's an extremely difficult
language.
Yet I'll try to form my question:
It is about the continue statement in python.
I wrote this code
i = 0
while (i < 10):
if i == 5:
continue
print i
i+=1
What i expected was an output like
1
2
3
4
6
7
8
9
Exactly what I expected at first glance, but...
Instead it seems to freeze after 4. The shell input symbol is blinking.
I bet this is easy enough for pros but I really got my problem with
understanding the reason why.
You've written an infinite loop. After 4 is printed i is incremented to
5. As i is less than 10 the loop is entered. The test for i == 5 is
true so the loop continues, skipping the increment of i. So i will
never vary, the loop will keep running and the test for i == 5 is true
so the loop continues, skipping the increment of i...
Okay thank you people, I go now learn better english ^^
Your English was perfectly understandable. I suggest you concentrate on
your code :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor