Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

if input equals string, do something... python 2.7 [duplicate]

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

like image 705
Matt Walker Avatar asked Sep 07 '25 23:09

Matt Walker


1 Answers

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
like image 164
user1525721 Avatar answered Sep 09 '25 22:09

user1525721