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 trialKrist贸f Dombi
28,047 PointsCan't fix a SyntaxError in one of the first lessons
Unfortunately I cant find out how to fix a SyntaxError in one of the first lessons. I know the mistake is in, or at least 99% sure it's in the print(5 + "a") part, as this is unlogical but atm not sure how to fix it. Thanks for the help.
print("Hello") def (name)
print("Let's do some math!") print(5 + "a")
print("Thanks for playing along!")
print("Hello")
def (name)
print("Let's do some math!")
print(5 + a)
print("Thanks for playing along!")
2 Answers
reanimator313
6,005 Points"a" is not defined:
a=something
and the first part
name="A name"
print("Hello")
print(name)
Christian Mangeng
15,970 PointsHi Kristof,
your assumption is correct. print(5 + "a") does not work because it's not possible to add an integer to a string. What would work is print("5" + "a"), as both values are strings, or print(5 + a) if you assigned an integer value to a before using that print command (e.g. a = 2). However, also def (name) is no valid syntax, as "def" is the keyword reserved for defining functions.