pocketpy/tests/45_yield.py
blueloveTH ff98646064 ...
2023-04-17 19:25:55 +08:00

13 lines
147 B
Python

def f(n):
for i in range(n):
yield i
x = 0
for j in f(5):
x += j
assert x == 10
a = [i for i in f(6)]
assert a == [0,1,2,3,4,5]