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 trialBenjamin Hsu
270 PointsHaving issues on challenge task 1 of 2 with functions
trying to write function that should receive one argument Name. Function should return one value which is the string 'hello' followed by value of name parameter.
def hello_student(name): val=name return val print ('hello_val')
Getting error saying output is not correct
def hello_student(name):
val=name
return val
print ('hello_val')
1 Answer
Maxwell Newberry
7,693 PointsHi Benjamin,
The first task is asking us to return the value Hello [name that was passed]. You are very close in your function:
def hello_student(name):
return "Hello " + name
The function above returns the string "Hello " plus we concatenate the name that was passed through the function. Note: Note the space after the Hello within the string.
The second task asks us to assign the return value of the function to a variable called hello
, not print it out. So we want to initialize a variable then call our function.
def hello_student(name):
return "Hello " + name
hello = hello_student("Benjamin")