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

Shane Smith
Shane Smith
Python Development Techdegree Student 2,078 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?
def hello_student(name):
    return "Hello "+name

    hello = return

1 Answer

18,754 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!