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

60,902

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
Share:
60,902
Matt Walker
Author by

Matt Walker

Hi there, My name is Matt and I am attending university for Computer Science. In my spare time I do some internet marketing, building and selling websites with unique ideas. I am pretty good with SEO (Search Engine Optimization). I doubt I will be able to answer much here, but to the people who help me with problems, thanks!

Updated on September 28, 2020

Comments

  • Matt Walker
    Matt Walker over 3 years

    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