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 trialAmar P
1,983 Pointscreating_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
hello_student("Ashley")
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
hello_student("Ashley")
2 Answers
Ryan Groom
18,674 PointsAmar 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!
Mark Nembhard
1,387 PointsThose first two lines do not seem to work even though it makes sense
Amar P
1,983 PointsAmar P
1,983 PointsThanks 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?
Ryan Groom
18,674 PointsRyan Groom
18,674 PointsAmar 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.