-2

Everything left out of what is shown is correct because I tested it before...

no matter what i put, it still says "That is not a choice" which is my else statement

1 = choice1

2 = choice2

3 = choice3

while True:
    choice = raw_input("->")
    if choice == 1:
        dochoice1
        break
    elif choice == 2:
        dochoice2
        break
    elif choice == 3:
        dochoice3
        break
    else:
        print "That Is Not A Choice"
        continue
DuckyQuack
  • 39
  • 10

1 Answers1

1

raw_input returns a string, which you're comparing to integers, either convert choice to int, or compare it to string:

choice = int(raw_input("->"))

or:

if choice == "1":

If the user inputs something that's not a valid int, you can catch the exception:

try:
    choice = int(raw_input("->"))
except ValueError:
    print "Invalid int"
    continue
Francisco
  • 10,918
  • 6
  • 34
  • 45