[Tutor] While and for loops

Todd Matsumoto tmatsumoto at gmx.net
Tue Jul 14 08:49:59 CEST 2009


Hello,

The other day I was playing with a while loop with a for loop nested inside.

Within the for loop I had a condition to break the loop, but when loop ran it never existed the loop. I went back and looked in Programming Python to read about loops and I've got two questions (related to each other).

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?

while True:
    <do something>
    for i in items:
        if i > 10:
            break
        else:
            <do something>


-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01


More information about the Tutor mailing list