xxxxxxxxxx
from typing import Union
def multiply(value: Union[int, float], factor: Union[int, float]) -> Union[int, float]:
return value * factor
result = multiply(5, 2.5)
print(result) # Output: 12.5
xxxxxxxxxx
# Union typing can be used like this:
Union[int, str]
# In function defintion it would look like this:
def func(x: Union[int, str]) -> Union[int, str]: