yield none example

This commit is contained in:
Mert Gör ☭ 2023-09-06 18:56:01 +03:00
parent 6fed23b2ed
commit b7f1d07142
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 13 additions and 0 deletions

View File

@ -0,0 +1,13 @@
def bar(n):
for i in range(n):
print('New iteration')
yield i
print('end')
print(type(bar)) # <class 'function'>
g = bar(3)
print(type(g)) # <class 'generator'>
for i in g:
print(i)