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 trialRyan Carrillo
609 PointsName 'name is not defined
Hello,
I understand the code is looking for the name but its not finding one. How would I put in the function so the name would be defined?
print("Hello")
print(name)
print("Let's do some math!")
print(5 + "5")
print("Thanks for playing along!")
1 Answer
Steven Parker
231,275 PointsSince the instructions aren't specific, there's two different ways to solve this. One would be to replace the word name with some literal value, like a number or a string in quotes.
The other would be to define name before the line that uses it, for example:
name = "Joe"
print(name) # now it is defined and won't cause an error