def odd(n: int): for i in range(1, n + 1, 2): yield i # Test print(list(odd(7))) # [1, 3, 5, 7] print(list(odd(8))) # [1, 3, 5, 7]