0

I defined the following code for "Guess the bird game"

print("Hello, welcome to the guess the bird game! You can guess 3 times. GOOD LUCK!")
bird = "robin"

guess_bird = input('First try to guess the bird, please fill in your answer:')

if guess_bird == bird:
    print("Congratulations, you have it right!")

else:
    guess_bird = input("Unfortunately.. Once again, don't give up!"
    if guess_bird == bird:
        print("Congratulations, you have it right!")
    else:
        guess_bird = input("Last try to guess the bird, you can do it!")
        if guess_bird == bird:
            print("Congratulations, you have it right!")

        else:
            print("Sorry, no more tries...")

However, I get an error... How can I fix this? The error is:

File "<ipython-input-6-787643515908>", line 12
    if guess_bird == bird:
                         ^
SyntaxError: invalid syntax
2
  • 1
    You haven't closed the parentheses on the previous line. Commented May 1, 2020 at 23:14
  • The title mentions a nested function, yet there doesn't appear to be any in the code? Commented May 1, 2020 at 23:23

3 Answers 3

1

You're missing a closing parenthesis ) on the line guess_bird = input("Unfortunately.. Once again, don't give up!".

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

Comments

0

guess_bird = input("Unfortunately.. Once again, don't give up!" that line should have a closing paren. It is trying to include if guess_bird == bird: in the arguments to input.

Comments

0

You're missing a closed parenthesis.

Where you've written

guess_bird = input("Unfortunately.. Once again, don't give up!"

it should be written as

guess_bird = input("Unfortunately.. Once again, don't give up!") #add the ')' at the end

I added a repl.it for reference.

https://repl.it/repls/SugaryUncomfortableComputing

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.