Newbia alert .. working my way through Easy Python Montana Edu page, need help..

Highwaykind kwdotbenninkNOSPAM at 12move.nl
Fri Sep 20 11:07:32 EDT 2002


Thank you very much !
It's working now :)
After I finished the tutorial I'll try to translate it into Dutch ( 
which makes it even easier for me and probably other Dutch people .. ) 
Didn't know what an indentation was ( desperately looking for a 
dictionary LOL ).
Will go on with the tutorial .. and if I get stuck again and can;t 
figure out what I've done wrong this time I'll be back .. on my way to 
becoming a progammer .. in 2010 or so :)

Corien


> Highwaykind wrote:
>         ...
> > def print_options() :
> 
> You define this function, but never call it anywhere.
> 
> > choice = 'p'
> > while choice != 'q':
> >     if choice == 'r':
> >         a=input ("width")
> >         b=input ("height")
> >     print "result",rect (width,height)
> 
> Note that the print is NOT aligned with the input calls, but
> rather with the if statement.  Thus, the print (and its call
> to rect) is not conditional -- it happens even when choice
> is NOT 'r'.  This is unlikely to be what you want, so, indent
> this print statement 4 more spaces rightwards.
> 
> However, the crux of your problem is another:
> 
> > But the thing keeps telling me width is not defined, also I can;t use
> 
> Inddeed, width is not a defined variable: what you obtained
> from the call to input("width") you did not assign to the
> name width, but rather to the name a.  Therefore, the variable
> that is defined once this statement has executed is named a.
> 
> Therefore, change your call to rect  to rect(a,b) -- and
> similarly for the following passages in your code.
> 
> > the ELIF command .. THink I could do with some help :)
> 
> The reason you can't use elif (not a 'command' -- a clause
> in an if statement) is probably the indentation problem I
> mentioned earlier -- once you fix that you can probably
> also change the following if's to elif's (not the first one
> of course).  When indentation returns to the same level as
> the word 'if', it means the if statement is over: therefore
> you cannot "reprise" it later, continuing it, so to speak,
> with an elif clause.  Once you correct the indentation of
> the print statements, this will change.
> 
> 
> Alex
> 
> 

-- 
For the correct e-mail address : remove NOSPAM and replace dot with .



More information about the Python-list mailing list