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

Aiden van der Berg
Aiden van der Berg
4,963 Points

I need a little help

Why is there a name error coming through when I thought it was right?

creating_functions.py
def hello_student(name):
    return "Hello " + name

hello_student(name)

1 Answer

boi
boi
14,241 Points

Hello there Aiden,

There are two problems with your code, the 1st is the code you displayed here, the 2nd is you did not fulfill the challenge requirements.

Let's analyze the 1st problem;

 def hello_student(name): 
    return "Hello " + name

The first two lines of your code have no problems, which is displayed above.

hello_student(name) #Here is the problem

The problem arises in the function call hello_student(name), you passed in name as an argument, you told the program that name is a variable or that name has a stored value, does name have a stored value? did you assign name to something?

Now what could have made sense, is that you passed in "name" instead of name, did you notice the difference?

Coming to your 2ND problem regarding the challenge requirements, the challenge whats you to make a variable called hello and assign to it the function call hello_student("Aiden").