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

subhash w
subhash w
1,143 Points

Am trying to print "Hello <name>" using function. but unable to print correct answer

As per the question, I tried to add an argument of name "name" and assigned it to a name. The function takes the name argument, and tries to print in format: 'Hello <name>' what is wrong with this?

Steven Parker
Steven Parker
231,269 Points

Please show the exact code you are submitting so we can take a look.

subhash w
subhash w
1,143 Points

def hello_student(xyz): return(print ("Hello {}".format(xyz)))

name = "name" hello_student(name)

1 Answer

Steven Parker
Steven Parker
231,269 Points

You need Markdown formatting to display code correctly. But assuming there's no indentation errors the issue with the function is that it should just return the string and not "print" anything.

Then for task 2:

  • the variable being assigned should be "hello" instead of "name"
  • the string "name" should not appear before the function call
  • the argument needs to be enclosed in quotes
hello = hello_student("name")