fork download
  1. def gen():
  2. for i in range(10):
  3. res = yield i
  4. if res:
  5. yield res
  6.  
  7. pushed = False
  8. g = gen()
  9. for x in g:
  10. print(x)
  11. if (x == 5) and (pushed == False):
  12. g.send(x)
  13. pushed = True
Success #stdin #stdout 0.01s 27712KB
stdin
Standard input is empty
stdout
0
1
2
3
4
5
6
7
8
9