Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python for Beginners Correct errors

David Lassen-Diesen
David Lassen-Diesen
184 Points


Hi there, I'm working on the errors.py document within python and I've hit the error message invalid syntax error and I can't see where the problem is? Hoping someone can help, Many thanks David Lassen-Diesen

print("Hello") print("Hello")
print(name) print("name")

print("Let's do some maths) print ("Let's do some maths"!)
print(5 + "a") print(5 + 5)
print("Thanks for playing along") print("Thanks for playing along"!)

2 Answers

Hi David,

The 5 + "a" line needs to be changed to "5" + "a" - add two strings together. The last line, you have the exclamation mark outside the string.

I corrected the code to this:

print("name") # add inverted commas

print("Let's do some math!")
print("5" + "a") # make 5 a string

print("Thanks for playing along!") # change the single quote to a double

I hope that helps,