next iterator example

This commit is contained in:
Mert Gör ☭ 2023-09-06 20:00:11 +03:00
parent 682e04acbe
commit f950c99479
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,11 @@
def foo():
x = yield
print(x)
try:
iterator = foo()
val = next(iterator) # val = iterator.send(None)
print(val)
next(iterator) # iterator.send(None)
except StopIteration:
pass