← back to unit
Easy
# basics functions
Defining and Calling a Function
def creates a function — a named block of code you can run again and again by calling it (writing its name followed by parentheses):
def greet():
print("Hello there!")
greet()
greet()
prints:
Hello there!
Hello there!
Your turn: define a function called cheer that prints exactly these two lines:
Go team!
You've got this!
Then call cheer 2 times.
💡 need a hint?
pyb-func-def-no-return.py
loading...