[Tutor] While and for loops

Todd Matsumoto tmatsumoto at gmx.net
Tue Jul 14 09:00:26 CEST 2009


Okay,

So how would you break out from this situation?

T
-------- Original-Nachricht --------
> Datum: Tue, 14 Jul 2009 06:57:41 +0000
> Von: sli1que at yahoo.com
> An: "Todd Matsumoto" <tmatsumoto at gmx.net>
> Betreff: Re: [Tutor] While and for loops

> Your break is for the for loop not the while. The condition true never
> goes false so your in a infinite loop
> Sent from my Verizon Wireless BlackBerry
> 
> -----Original Message-----
> From: "Todd Matsumoto" <tmatsumoto at gmx.net>
> 
> Date: Tue, 14 Jul 2009 08:49:59 
> To: <tutor at python.org>
> Subject: [Tutor] While and for loops
> 
> 
> 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
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
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