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

This function is broken. I have no clue how to solve it.

So I ran into the awkwardly formulated code challenge, and I have no clue whatsoever of how I am supposed to be solving this.

Anyways, I hope someone have the know-how of how you're supposed to be writing this code!

creating_functions.py
def hello_student(name):
    hello = "Hello {}".format(name)
    return hello

hello_student(Buster)

2 Answers

Steven Parker
Steven Parker
231,060 Points

The argument needs to be a string, and literal strings must be enclosed in quotes.

Also, the instructions say to "save the return value to a variable called hello." So the function needs to be called as part of an assignment to create the new variable.

Thanks, Steven Parker! I’m not sure if I have understood this correctly, but it didn’t work out when I tried this either:

hello = return("Hello {}".format(name))

(If that’s what you’re saying...)

Steven Parker
Steven Parker
231,060 Points

That looks like the line inside the function, which is OK as is.

I'm talking about the line at the very bottom for task 2:

hello_student(Buster)            # current code
hello = hello_student("Buster")  # fixed
Devin Lane
Devin Lane
4,575 Points

I got tripped up on this too and forgot to pass my argument as a string with quotation marks. Thanks for asking and answering this question!