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 trialsubhash w
1,143 PointsAm 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?
subhash w
1,143 Pointsdef hello_student(xyz): return(print ("Hello {}".format(xyz)))
name = "name" hello_student(name)
1 Answer
Steven Parker
231,269 PointsYou 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")
Steven Parker
231,269 PointsSteven Parker
231,269 PointsPlease show the exact code you are submitting so we can take a look.