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

I don't understand this code challenge

I don't know why val is not defined in my code

creating_functions.py
def hello_student(name):
    val = name
    return val
print("Hello", val)

2 Answers

Steven Parker
Steven Parker
229,783 Points

You're close, but the challenge wants you to combine "Hello " with the name in the function and have it return that.

You also won't need to "print" anything for this challenge.

Steven Parker
Steven Parker
229,783 Points

You need to combine the two strings using concatenation, with a + sign instead of a comma. And you need to add a space to keep the words separate:

    return "Hello " + val

Also, you could skip creating the extra variable and just use the parameter directly in the return expression.

I still don`t understand

def hello_student(name):
    return( "Hello" +  name )
Steven Parker
Steven Parker
229,783 Points

Almost there, but you still need to add a space to keep the words separate (see my example).