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 trialGrayden Kellogg
Python Development Techdegree Student 1,826 PointsReturning values in functions
I'm a little confused by the wording of this question I think. The task says " write a function called hello_student. This function should receive one argument, name. This function should return one value, the string "Hello" , followed by the value of the name parameter. Why won't my code work?
def hello_student(name):
name1 = "Hello " , name
return name1
3 Answers
jb30
44,806 PointsFor your current code, the checker gives AssertionError: ('Hello ', 'Ashley') != 'Hello Ashley'
. This means that the function is returning the tuple ('Hello ', 'Ashley')
and not the string 'Hello Ashley'
.
To combine the strings, use +
instead of ,
Grayden Kellogg
Python Development Techdegree Student 1,826 PointsI should of thought of that. Thank you
Andy Hughes
8,479 Pointsjb30 is spot on as always :)
But also, in the interest of less is more; you don't actually need to create the variable 'name1' to pass the challenge. You can just return 'Hello ' + name. That's enough to pass the challenge. :)
Grayden Kellogg
Python Development Techdegree Student 1,826 PointsVery true. Thank you
Grayden Kellogg
Python Development Techdegree Student 1,826 PointsGrayden Kellogg
Python Development Techdegree Student 1,826 PointsI tried other syntax's and logic too and couldn't get it to work. I'm getting an error from this code saying "Hello Ashley" != to "Hello Ashley". I'm confused