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 Python Basics (2015) Python for Beginners Correct errors

David Lassen-Diesen
David Lassen-Diesen
184 Points

Error.py

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

errors.py
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("Hello")
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,

Steve.