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 trialElton Mungani
647 PointsFunction calling
How come when I preview my code, I get 'Hello Elton' but the interpreter regards it wrong? Possible spelling or spacing error. Please assist
def hello_student(name):
val = 'Hello' + name
return val
print(hello_student(' Elton'))
1 Answer
Steven Parker
231,248 PointsThe instructions say the function should return "the string 'Hello ' followed by the value of the name parameter" (notice the space is with 'Hello '
).
But in your function the built-in "Hello
" has no space, so you had to add one to the argument you passed. Fix it so you can pass in just a name and should pass the challenge.
Elton Mungani
647 PointsElton Mungani
647 PointsThanks, that worked!
So then how then are you supposed to do the 2nd task whilst adding to the 1st one?
"Call the hello_student() function and save the return value to a variable called hello."
Steven Parker
231,248 PointsSteven Parker
231,248 PointsYou didn't need to print for the challenge, so just change the print into an assignment:
hello = hello_student('Elton')