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!

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


Can't find cause of syntax error in this code.

first_name = input("What is your first name? ") last_name = input("What is your last name? ") if first_name == "Josh": print(first_name, "is learning python\n") elif first_name == "Sam": print("Thank you for signing up for our free trial", first_name) else: age = int(input("What is your age?") if age <= 9: print("We'd like to offer you a {} free subscription trial to learn programming languages such as; {}. Please fill in your first and last name below".format("7 day", Python, Java, CSS, HTML")) print("We at {} take pride in our excellent teaching facilities and academic record, please allow up to a maximum of 7 days for the delivery of your new {} pass smartcard".format('Google', 'Python')) else: if age >= 18: print("Wow, you're all grown now! {} is an awesome age to be. Don't forget to stop and smell te roses from time to time!".format(age))

It's giving a syntax error for line 9. The colon. Any help would be appreciated!

Steven Parker
Steven Parker
225,757 Points

To make it possible for folks to help, you'll need to show your code, and probably also provide a link to the course page you are working with.

Posted code must be formatted so the spacing shows up (in Python, indentation is everything). Use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

1 Answer

Steven Parker
Steven Parker
225,757 Points

It's very hard to read unformmated code, but it looks like on the line where "age" is assigned (probably line 8), the parentheses are unbalanced:

    age = int(input("What is your age?")  # <-- close parenthesis ) missing

It also looks like there may be unbalanced quotes on the line with the subscription message.