Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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