[Tutor] Menu not working properly

Jason MacFiggen jmacfiggen at gmail.com
Mon Aug 2 12:21:35 CEST 2010


My problem is choice 3. Exit, if you select no or put an invalid answer...
It will run menu1... but then it runs
    name = raw_input ("Enter your character name. ")
    print "Your character name is:", name

How can i make it so it prints menu1 like normal... then asks you to enter
your selection again?
instead of running the above code.

-Thank you

import sys

def menu():
    menu1 = """
Pick A Class From The Menu or choose Exit.
1. Warrior
2. Mage
3. Exit
            """
    print "Welcome to Iris's Last Breath"
    print menu1
    characterChoice = input ("Enter your choice. ")
    print

    if characterChoice == 1:
        print """

*Place Holder*

        """

    elif characterChoice == 2:
        print "Currently under construction.\nPlease choose again."
        print menu1
    elif characterChoice == 3:
        endProgram = raw_input ("Do you want to end program? yes or no ")
        if endProgram == "yes":
            sys.exit(0)
        elif endProgram == "no":
            print menu1
        else:
            print "\nInvalid Command:\nSelect from the menu again.\n"
            print menu1

    print
    name = raw_input ("Enter your character name. ")
    print "Your character name is:", name
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100802/fe3777b1/attachment.html>


More information about the Tutor mailing list