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

guys im stuck on this task:

Call the hello_student() function and save the return value to a variable called hello.

creating_functions.py
def hello_student(name) :
    return 'Hello ' + name
   hello_student()
    print (hello)

1 Answer

Charlie Thomas
Charlie Thomas
40,856 Points

So there are two parts to this question: the first part is to call the hello_student function. To do this you write the name of the function, an opening bracket, any parameters you're going to pass to the function, and then a closing bracket. In the case of this function, it takes one parameter - name. So we'd write it as:

hello_student("Charlie")

The second part asks us to store this in a variable called name. As a recap, in Python, we declare a variable by writing the variable name followed by an equals sign followed by the value of the variable. For example, to set the variable a equal to three we would write:

a = 3

Now putting these parts together we create a variable called hello and store the value from hello_student function in it.

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

name = hello_student("Charlie")

i'm still getting an error