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 Functions, Packing, and Unpacking Getting Info In and Out of Functions Functions with Arguments and Returns

NameError

My code says "name is not defined", what could be the problem?

creating_functions.py
def hello_student(name):
    name = input('Enter your name:')
    return name
    print('Hello', hello_student(name))

hello_student(name)

2 Answers

Hi 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!

Thanks a lot Ave Nurme, that was very helpful. Cheers!

Happy to help! :)