Python Functions, Packing, and Unpacking Getting Info In and Out of Functions Functions with Arguments and Returns

Shane Smith
seal-mask
.a{fill-rule:evenodd;}techdegree
Shane Smith
Python Development Techdegree Student 1,555 Points

Beginner challenge help!

I know that in line 4 i cant call the function i defined without passing it a parameter but I am unsure of how to proceed?

creating_functions.py
def hello_student(name):
    return "Hello "+name

hello_student():
    hello = return

1 Answer

rydavim
MOD
rydavim
Treehouse Moderator 18,641 Points

Alright - so the return statement you wrote while defining the hello_student function is what you'll be using to "generate" the value of your new hello variable.

def hello_student(name): # from task 1
  return "Hello " + name 

hello_student(): # no colon for function calls
    hello = return # the return statement is part of the function

Instead of thinking of it like writing a function, you're using the function you already wrote to save the result to a new hello variable. hello_student(rydavim) would return the value "Hello rydavim", but that isn't being saved anywhere unless you assign it to a variable.

# create a variable to save the return value of a function
def exampleFunction(item):
  return "Your item is: " + item

exampleVariable = exampleFunction(blueberries)
# exampleVariable is now set as "Your item is: blueberries"

Hopefully that gets you going, but let me know if you've still got questions. Keep it up!