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 trialEkenedilichukwu Osubor
1,661 PointsCan'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!
1 Answer
Steven Parker
231,275 PointsIt'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.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsTo 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. Â Or watch this video on code formatting.