The comments mention another way of typing the solution. My solution is as follows:
"""
Koan to learn annotating the Python list of various type of elements
"""
from typing import Union, List
# Annotate mixed type-values. There are two-ways to annotate this
nos: list[Union[int, float]] = [1, 2.0, 3.5]
# Annotate the list of int to list of better types
squares: list[Union[int, float]] = [no * no for no in nos]
I suppose this could be one way to annotate. Would just like to check what the other way is.
The comments mention another way of typing the solution. My solution is as follows:
I suppose this could be one way to annotate. Would just like to check what the other way is.