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

Grayden Kellogg
seal-mask
.a{fill-rule:evenodd;}techdegree
Grayden Kellogg
Python Development Techdegree Student 1,826 Points

Returning 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?

creating_functions.py
def hello_student(name):
    name1 = "Hello " , name
    return name1
Grayden Kellogg
seal-mask
.a{fill-rule:evenodd;}techdegree
Grayden Kellogg
Python Development Techdegree Student 1,826 Points

I 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

3 Answers

For 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 ,

Andy Hughes
Andy Hughes
8,479 Points

jb30 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. :)