from typing import Union # Usage: Union[type1, type2] # Exemple: weight : Union[int, float] # or def return_triple( number : Union[int, float]) -> Union[int, float]: return number*2
Here is what the above code is Doing:
1. We’ve defined a variable weight that can be either an int or a float.
2. We’ve defined a function return_triple that takes an int or a float as an argument and returns an int or a float.