I would like to explain why it is better to keep the output type as constant as possible regardless of value of inputs by implementing a similar function in two different ways.
If we need a function which returns a list of multiples of three from given list of integer, a function is simply like this:
def extract_multiples_of_three(values: List[int]) -> List[int]:
return [v for v in values if v % 3 == 0]