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 trialTinayeshe Ngara
3,955 PointsNameError
My code says "name is not defined", what could be the problem?
def hello_student(name):
name = input('Enter your name:')
return name
print('Hello', hello_student(name))
hello_student(name)
2 Answers
Ave Nurme
20,907 PointsHi Tinayeshe
In this challenge two rows are actually needed to complete it. Let's read the instructions line by line.
1) Write a function called hello_student
def hello_student:
2) This function should receive one argument, name
def hello_student(name):
3) This function should return one value, the string 'Hello ' followed by the value of the name parameter
return 'Hello ' + name
And that's it! Please note the space in the return statement in 'Hello '. For instance, we want to return Hello Tinayeshe and not HelloTinayeshe.
So when we put the lines together we get:
def hello_student(name):
return 'Hello ' + name
Hope this helps!
Ave Nurme
20,907 PointsHappy to help! :)
Tinayeshe Ngara
3,955 PointsTinayeshe Ngara
3,955 PointsThanks a lot Ave Nurme, that was very helpful. Cheers!