「python」while文を利用するサンプル

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# coding: utf-8
def funcA(a):
while a < 10:
yield a
a += 1
nn = funcA(0)
print(next(nn))
print(next(nn))
# coding: utf-8 def funcA(a): while a < 10: yield a a += 1 nn = funcA(0) print(next(nn)) print(next(nn))
# coding: utf-8

def funcA(a):
      while a < 10:
            yield a
            a += 1

nn = funcA(0)

print(next(nn)) 
print(next(nn))

実行結果
0
1

Python

Posted by arkgame