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 trialKeegan Swanson
1,339 Pointsfunctions with arguments and returns
This doesn't make complete sense to me; Can I get a little help please
def hello_student(name):
'Ashley' != 'Hello Ashley'
return 'Hello Ashley'
1 Answer
KRIS NIKOLAISEN
54,972 PointsYou have created a function named hello_student
that has a parameter named name
and returns Hello Ashley
def hello_student(name):
'Ashley' != 'Hello Ashley'
return 'Hello Ashley'
You can call the function and print the results as follows
print(hello_student("Keegan"))
and the output is
Hello Ashley
You can store the result of the function in a variable
hello = hello_student("Bob")
and print the result
print(hello)
and the output is still
Hello Ashley
The challenge wants you to return 'Hello ' followed by the value of the name passed in. You can do this with concatenation. This allows you to pass in different names and achieve different results.
return 'Hello ' + name
In between this you have this line:
'Ashley' != 'Hello Ashley'
Is there a reason for this? What do you think this line does? If you remove this line and modify the return statement
def hello_student(name):
return 'Hello ' + name
You can then call the function and print the result
print(hello_student("Keegan"))
and the output is
Hello Keegan
Or store the result of the function in a variable
hello = hello_student("Bob")
and print the result
print(hello)
and the output is
Hello Bob