What is the output?
def g():
x = yield 1
yield x * 10
it = g()
print(next(it), it.send(4))
- 1 None
- 1 10
- 1 40
- 4 40
next() runs to the first yield and returns 1. send(4) resumes the generator with x = 4 and runs to the next yield, returning 40.
Play Problem Solving ▸