Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Complex types

  • For Python 3.9+

things: list = ["snake", 42]
#things: list[str] = ["snake", 42]

numbers: list[int] = [23, 19, 42]

mapping: dict[str, int] = {
        "Perl": 4,
        "Python": 6,
        "Rust": 4,
        "PHP": 3
}

info: tuple[str, int, bool] = ("Python", 3, True)