paulnewbie34
paulnewbie34

Reputation: 17

Respond to inputs in Python

I am trying to make a simple game for learning English grammar using Python. Basically, the user inputs the verb form and Python should return 'correct' or 'incorrect'. I am trying to do this using a function:

def simple_past():
    question1 = input('I ____ to the park. Input: ').lower()  
    if input == 'went':
        print('correct')
    else:
        print('incorrect')

But when I type in 'went', it always sends back 'incorrect'. My question is twofold: (1) why is it returning 'incorrect' even thought I am typing in 'went', (2) is this the best way to make this kind of activity? Cheers

Upvotes: 0

Views: 527

Answers (2)

Rajendra Kumbar
Rajendra Kumbar

Reputation: 7

That is the reason we should give meaningful names to variables.

def simple_past():
    input_value = input('I ____ to the park. Input: ').lower()  
    if input_value == 'went':
        print('correct')
    else:
        print('incorrect')

Upvotes: 0

Frustrated Programmer
Frustrated Programmer

Reputation: 51

def simple_past():
    question1 = input('I ____ to the park. Input: ').lower()  
    if question1 == 'went':
        print('correct')
    else:
        print('incorrect')

Value from input will be stored in the question1 variable. So you should be comparing question1 and 'went'

Upvotes: 3

Related Questions