[Tutor] Return to main menu

K J game at gameweave.com
Tue Jun 29 01:51:35 EDT 2004


Well this is the little program that I have created it is my first one and it works just
fine from what I have tested. Only problem I have with it is that, lets say you enter
1 at the prompt it will load the add.py modual. however when it comes to the end
of the modual it terminats. How would I go about making it so that it will return to 
the menu and ask for another choice.

Kevin

print """
0 Exit
1 Add
2 Subtract

"""
number = raw_input("Enter a number: ")

while 1:
        try:
            number = int(number)
            break
        except ValueError:
            print "That is not an option"
            number = raw_input("Enter a number: ")
if int(number) == 1:
        import add
if int(number) == 2:
        import subtract
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040629/6a34827c/attachment.html


More information about the Tutor mailing list