Courses/Modern Python

๐Ÿš€ Modern Python

Type Hints

Annotate function signatures for clarity and tooling.

Type hints don't change runtime behavior โ€” they document intent and power editor autocomplete and static checkers like mypy.

def greet(name: str, times: int = 1) -> str:
    return ("hi " + name + " ") * times

Use list[int], dict[str, float], Optional[X] (or X | None) for richer types.

main.py
Output
Press Run to execute.
Expected output
5

Sign in to track your progress across lessons.