Problem Statement
What is the main benefit of adding type hints to a codebase?
Explanation
Hints help editors, linters, and CI catch mismatches before runtime. They also act as living documentation that improves readability.
Use a checker like mypy or pyright. Hints do not enforce types at runtime unless you add validators.
Code Solution
SolutionRead Only
from typing import List
def total(xs: List[int]) -> int:
return sum(xs)