Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Functions, Packing, and Unpacking Getting Info In and Out of Functions Functions with Arguments and Returns

Nicole A
Nicole A
1,790 Points

function not working

Function does not appear in green when I try to call it.

creating_functions.py
def hello_student(name):
    val = ( 'Hello Ashley' )
    return val

hello_student(name)

2 Answers

Steven Parker
Steven Parker
218,692 Points

It looks like you "cheated" in task 1 by imbedding the value in the string that the check mechanism uses to test the function. So instead of the string "Ashley", the function should construct a string using the name variable. That way, it will work with any supplied argument.

Then, task 2 tells you to "Call the hello_student() function and save the return value to a variable called hello." So along with calling the function, you'll need to assign the result to a new variable named hello. Also, instead of the parameter name you should supply a string as an argument (it can contain anything you like).

Steven Parker
Steven Parker
218,692 Points

You nearly had it, you only needed to add the operator + to join the two strings. Also, the parentheses aren't needed.

Glad I could help.

Nicole A
Nicole A
1,790 Points

Thank you Steven. I had initially written val = ("Hello " name) but I kept getting an error message saying "Hello Ashley not found" hence my "cheating"