0
def game():    

modex = False
while modex == False:
    mode = raw_input("please select a mode: ")
    try:
    ## THE PROBLEM IS HERE!
        int(mode)
        if mode == 1:
            modex = True
            break
        elif mode == 2:
            modex = True
            break
        elif mode == 3:
            modex = True
            break
        else:
            print "invalid #. try again"
            modex == False
            continue

    except:
        print "invalid # try again"
        continue
game()

i can't seem to turn mode into an integer, for example:

input: 1 output: invalid # try again

for the game i am making i have 3 modes hence the 3 modes if statement in the try-except statement

could you please help me? I am using python 2.7

Telekey
  • 1
  • 1
  • 6

1 Answers1

1

Asign the int(mode) value to something. Best approach: mode = int(mode)

You can also try: mode = int(raw_input:('please select a mode:'))

implicati0n
  • 269
  • 2
  • 10