Skip to content
AgileLogics
4 min read

Function Arguments

Prerequisites: Functions

A parameter can have a default value, used when the caller doesn't provide one. Arguments can also be passed by name (keyword arguments), regardless of their order.

def make_user(name, role="member"):
    print(f"{name} is a {role}")

make_user("Ada")                     # uses the default role
make_user("Grace", role="admin")     # overrides it
make_user(role="admin", name="Ada")  # keyword args can be reordered

Expected output

Ada is a member
Grace is a admin
Ada is a admin