Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Why there is a syntax error in my Number game app?

it keeps saying there is a syntax error on else: (the one under except valueerror)

def game(): 
    import random
    secret_num = random.randint(1,8)    
    while len(nums) < 5:
        try: 
            num = int(input("what's your guess? "))
        except ValueError:
            print("{} is not an integar! ".format(num)
        else:
            if num == secret_num:
                print("Congrats! The number is {}".format(secret_num))
                break
            else:
                too_low()
                too_high()
            nums.append(num)
    else:
        print("You didn't get it ! The number is {} !".format(secret_num))
    play_again = input("Do you want to have another go? y/n ")
    if play_again.lower() == y:
        game()
    else:
        print("bye for now!")

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Gray;

On that line, it looks like you are missing a closing parenthesis. That would definitely cause a syntax error message.

Post back if you are still stuck and happy coding.

Ken

Thank you so much Ken!