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 trialMarlon Jay Chua
4,281 PointsCannot understand challenge task 2 of 2 on creating_functions.py. Please help.
I'm confused with assigning a variable on the return value, I already did on task 1 of 2. Please help. Thanks.
def hello_student(name):
var = 'Hello ' + name
return var
hello_student()
1 Answer
Tim Danner
3,284 PointsYou'll need to save the return value of the function to a variable named hello
, like so:
def hello_student(name):
var = 'Hello ' + name
return var
hello = hello_student('your name')
You can also return the value without declaring another variable inside the function:
def hello_student(name):
return 'Hello ' + name
hello = hello_student('your name')