Puzzle 29: Explanation
Let’s learn about type annotations in Python.
Try it yourself
Try executing the code below to verify the result:
Python 3.8
def add(a: int, b: int) -> int:return a + bval = add('1', '2')print(val)
Explanation
Python 3 added support for type hints. As the name suggests, though, they’re only hints that are not enforced by the Python interpreter. The only thing Python does with these hints (sometimes called annotations) is to add them to ...