Skip to content

103-easy-mixed-values discussion #8

@J0

Description

@J0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions