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 trialHarjan Anand
780 Pointsi am so confused about this question dont know whats wrong and what to do next,
?
def hello_student(name):
print(name)
val = name
return val
hello_student(hello)
1 Answer
jb30
44,806 PointsThe challenge is expecting you to return the string formed by combining 'Hello '
with the value of the parameter name
. To combine the strings with string concatenation, you can use +
between the strings: 'Hello ' + name
. To combine the strings with string interpolation, you could use f'Hello {name}'
or 'Hello %s' % name
or 'Hello {}'.format(name)
.
You don't need to call print
or assign the value of name
to a new variable.
In the line hello_student(hello)
, hello
is treated as a variable, but you haven't defined a value for it, so Python will give you a NameError. To pass the string 'hello' into the function, you would do hello_student('hello')
, which should return the string 'Hello hello'.