[Tutor] While and for loops
wesley chun
wescpy at gmail.com
Tue Jul 14 09:05:30 CEST 2009
> Can you run for loops in while loops and if yes, why did my if condition not break the loop?
>
> I read that loops sort of have an order of precedence, does that have anything to do with this problem?
todd,
welcome to Python! you're right in that your questions are related to
each other because the answer to both of your questions is the same:
you can only break out of the innermost loop (from where you have your
break statement). if you need to break out of the outer one, you need
another break statement not contained in another loop.
hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list