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

Functions with arguments and returns

This is extremely difficult, and I don't understand it. Please help.

creating_functions.py
def hello_student(name):
    return name 

print(Hello, name)

1 Answer

Steven Parker
Steven Parker
229,744 Points

Here's a few hints:

  • all the work for task 1 should be done inside the function
  • literal strings (not in a variable) must be enclosed in quotes
  • the "Hello " should be combined with the name as part of the return value.
  • you won't need to "print" anything

What? This still doesn't make sense.

Steven Parker
Steven Parker
229,744 Points

Some additional hints for the other hints:

  • "Inside the function" means between the "def" line and the "return" line.
  • A "literal string" such as the word "Hello " :point_left: needs quotes around it
  • the "Hello " needs to be combined with the name into a larger string
  • the larger string is what the function will return
  • the instructions do not ask you to use "print" for anything

And when you get to task 2, you will use the function you made for task 1 and assign the result to a variable.
You still won't need "print".

Thank you for the help on task one, I got through it, but now I need a little help on task two.

Steven Parker
Steven Parker
229,744 Points

As I mentioned before, task 2 basically is calling the function previously defined, and assigning the result to a variable.