カウンタ
351 ワード
ジェネレータを使う
def counts():
def f(): #
x = 0
while True:
x = x + 1
yield x
it = f()
def number():
num = next(it)
return num
return number
counts_demo = counts()
while True:
num = counts_demo()
print(num)
if num > 10:
break