next send

This commit is contained in:
Mert Gör 🇹🇷 2023-09-06 19:55:36 +03:00
parent b01dea087f
commit 682e04acbe
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 38 additions and 0 deletions

19
python-temel/next.send.py Normal file
View File

@ -0,0 +1,19 @@
def foo():
x = yield 10
print(x)
x = yield 20
print(x)
x = yield 30
print(x)
iterator = foo()
try:
val = next(iterator)
val = iterator.send(val * val)
val = iterator.send(val * val)
iterator.send(val * val)
except StopIteration:
pass

View File

@ -0,0 +1,19 @@
def foo():
x = yield 10
print(x)
x = yield 20
print(x)
x = yield 30
print(x)
iterator = foo()
try:
val = next(iterator)
val = iterator.send(val * val)
val = iterator.send(val * val)
iterator.send(val * Val)
except StopIteration:
pass