×

python · level 1 · unit 7 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

A is a slot where your function catches information.

Picture your function as a machine. Right now it does the same thing every time. Cut a slot in the front, and you can feed in something new on each go.

That slot is a parameter. It is a variable that lives in the brackets of the def line, like name in def greet(name):. Inside the function, use it like any other variable.

The value you drop in when you call is the . Call greet("Mia") and name holds "Mia". Call greet("Leo") and the same machine greets Leo instead.

def greet(name):
    print(f"Hello, {name}!")
greet("Mia")
greet("Leo")

Need two slots? Separate the parameters with commas, and the arguments too.