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

Eric Francke
Eric Francke
1,428 Points

How do you write a function that takes value, name, function should return one value, 'Hello' followed by value of name

function should take one value, name, and return one value, 'Hello ' followed by value of name

creating_functions.py

2 Answers

Asher Orr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Asher Orr
Python Development Techdegree Graduate 9,409 Points

Hi Eric- you can break the challenge down into steps:

"Write a function called hello_student."

def hello_student():

Functions in Python begin with def (define) followed by the name of the function. If your function takes any arguments, they will go inside the parentheses.

The colon at the end signals to Python that there's code within the function.

"This function should receive one argument, name."

def hello_student(name):

"This function should return one value, the string 'Hello ' followed by the value of the name parameter."

def hello_student(name):
    return {your code here!}

If you're confused about the last step, here's what the challenge is asking for:

"When I run this code:

hello_student("Eric")

This function:

def hello_student(name):
    return {your code here!}

Should be set up so that I see this printed to the terminal: "

Hello Eric

I suggest checking out this video: https://teamtreehouse.com/library/python-basics-3/returning-values

I hope this helps. Let me know if you have any questions!

Eric Francke
Eric Francke
1,428 Points

Thanks! That was very helpful!