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!

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

creating_functions.py has some issue

Whats the issue with this code?

def hello_student(name): new = print("Hello {}".format(name)) # new = print(name) return new


I pasted same code in another compiler & it gave me proper output of Hello Ashley

In preview its showing me Hello Hello Ashley

Can somebody help?

def hello_student(name):
     new = print("Hello {}".format(name))
    # new = print('name')
     return new


2 Answers

Amar Patekar Hey Amar, I recently answered this question a few days ago. The main thing you're missing here is that the question is actually asking you to store the result of the function call into a variable called "hello". This was my solution:

def hello_student(name):
     return ("Hello " + name)   
hello = hello_student("Ashley")

I believe it's a little bit simpler as well. Let me know if you have any questions!

Thanks Ryan. I checked the question again. Here is what i understand

Write a function called hello_student. - Done This function should receive one argument, name. - Done This function should return one value, the string 'Hello ' followed by the value of the name parameter. - Done Ryan Groom, where does it say to store the value in variable Hello?

Amar Patekar Sorry Amar, I should have specified that the second part of the question asks for you to store the result in a variable called "hello". So if you are just attempting to answer part 1 of the challenge, your solution should be only the first two lines from my answer.

Mark Nembhard
Mark Nembhard
1,387 Points

Those first two lines do not seem to work even though it makes sense