Caffeinated Coder
Book an appointment
Lesson 24 · Idiomatic Python

Type hints

A type hint is a note in your code that says what kind of value belongs where, such as n: int or -> int. Step through a five-line file, hints.py, to see what Python does with hints (it stores them and never checks them), why double("ha") quietly returns 'haha', and how a type checker, mypy, reads the same file without running it and flags the bug on line 5.

12 min9 steps5 questionsAdvanced
Fig 24 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.