[Tutor] Looks like Giant Calc is a bust.

Alan G alan.gauld at freenet.co.uk
Sun Jul 10 10:20:32 CEST 2005


> The Giant Calculator runs now, just not as I want it to. 
> I can't seem to get it past the main menu. 

See my other post. You are never returning the choice from 
the function so option is never changed from 0...

------------------
option = 0

def main_menu():
   print "OPTIONS MENU"
   print "1) Calculate"
   print "2) Shapes"
   print "3) Temperature"
   print "4) Formulas"
   print "5) Quit"
   option = input("What option would you like:" ) 


#Code for main part of program.
print main_menu()
if option == 1:
----------------------

You have created an option variable but you never change it.
you need to set option to the return value from main_menu()
and modify main_menu() to return the value.

One other option, but its bad proctice, is to declare option 
as global inside main_menu(), but returning the value is 
much better.

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


More information about the Tutor mailing list