0

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

2
  • 4
    if question1 == 'went': is what you should write Commented Oct 5, 2021 at 12:58
  • input is just a built-in Python function. In your second line you assign the return value of it to the variable question1 and it is that which you should check if it is == 'went' Commented Oct 5, 2021 at 13:00

2 Answers 2

3
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'

Sign up to request clarification or add additional context in comments.

Comments

0

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')

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.