pythonpython-2.7input

if input equals string, do something... python 2.7


Having trouble with the following code:

start_over = 1

question = input("Do you wish to try again? y/n: ")
if question == "y":
    start_over -= 1
else:
    raise SystemExit

If they enter y, it goes straight to the else condition.

Solved, was using input instead of raw_input


Solution

  • Just define start_over...it will work

    question = raw_input("Do you wish to try again? y/n: ")
    start_over = 10
    if question == "y":
        start_over -= 1
        print start_over
    else:
        raise SystemExit