$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · hard · #252

What is the output?

def g():
    x = yield 1
    yield x * 10

it = g()
print(next(it), it.send(4))
  1. 1 None
  2. 1 10
  3. 1 40
  4. 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 ▸