12 lines
215 B
Python
12 lines
215 B
Python
|
|
|
|
def odd(n: int):
|
|
for i in range(1, n + 1, 2):
|
|
yield i
|
|
|
|
print(list(odd(10))) # [1, 3, 5, 7, 9]
|
|
print(list(odd(7))) # [1, 3, 5, 7]
|
|
|
|
gen = odd(5)
|
|
print(next(gen)) # 1
|
|
print(next(gen)) # 3 |