[Tutor] figured it out

Magnus Lyckå magnus at thinkware.se
Fri Apr 23 06:22:45 EDT 2004


At 00:21 2004-04-23 -0400, Simonjthecat at aol.com wrote:
>Ok... with a little trial and error I figured it out by myself (yay!  this 
>is my first working program!)  I'll go ahead and put what I came up 
>w/....  Is this the most efficient way?  It seemed kinda weird to define 
>shape as the same thing twice but it works.
>Here it is.
>
>import sys #for exit command
>shape = raw_input("Which shape[1,2,3,quit]? ")
>
>while shape != 'quit':

[snip]

>    shape = raw_input("Which shape[1,2,3,quit]? ")

A common Python idiom is to do it like this:

while True:
     shape = raw_input("Which shape[1,2,3,quit]? ")
      if shape == 'quit':
         break
     ...rest of the code...



--
Magnus Lycka (It's really Lyckå), magnus at thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language 




More information about the Tutor mailing list