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

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
231,269 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
231,269 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"