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

Function calling

How come when I preview my code, I get 'Hello Elton' but the interpreter regards it wrong? Possible spelling or spacing error. Please assist

creating_functions.py
def hello_student(name):
    val = 'Hello' + name
    return val
print(hello_student(' Elton'))

1 Answer

Steven Parker
Steven Parker
230,274 Points

The instructions say the function should return "the string 'Hello ' followed by the value of the name parameter" (notice the space is with 'Hello ').

But in your function the built-in "Hello" has no space, so you had to add one to the argument you passed. Fix it so you can pass in just a name and should pass the challenge.

Thanks, that worked!

So then how then are you supposed to do the 2nd task whilst adding to the 1st one?

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

Steven Parker
Steven Parker
230,274 Points

You didn't need to print for the challenge, so just change the print into an assignment:

hello = hello_student('Elton')