We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Function Parameters

Function parameters can have type hints too! The syntax is the same as variable type hints: put a colon after the parameter name, then the type.

def greet_player(name: str):
    print(f"Welcome, {name}!")

When a function has multiple parameters, each one can have its own type hint:

def add_gold(current_gold: int, found_gold: int):
    return current_gold + found_gold

While adding a type hint to a variable declaration like:

character_health: float = 72.5

is considered a bit redundant due to type inference, adding type hints to function parameters is not redundant. If you don't add them, your tooling won't know what types the function expects, which makes autocomplete and error checking less effective.

Hover your cursor over the status variable. See how the tooltip can show you that it's a string? That's what makes type hinting useful! Note that name, level, health, and has_magic are all "unknown" because Python can't infer function parameter types without hints.

Assignment

Fantasy Quest's character status function already works, but its parameters aren't labeled yet. Add type hints to the parameters of get_character_status.

Don't change the function body.