Lesson 10 of 55
PythonArguments and Return Values
20 minutes
Course progress18%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 10 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Functions can accept positional, keyword, default, and variable‑length arguments.
def repeat(message, times=2):
return message * times
print(repeat('Hi')) # HiHi
print(repeat('Hi', 3)) # HiHiHi
repeat(message='Hi', times=3)).times=2) make an argument optional.*args to collect extra positional arguments and **kwargs for extra keyword arguments.