def f(x): yield x+1 print("test") yield x+2 g=f(10) print(next(g)) print(next(g))
a) No output
b)11 test 12
c)11 test
d) 11
def f(x): yield x+1 print("test") yield x+2 g=f(10) print(next(g)) print(next(g))
a) No output
b)11 test 12
c)11 test
d) 11
You must be logged in to post a comment.
b
Explanation: The code shown above results in the output:
11
test
12
This is because we have used next(g) twice. Had we not used next, there would be no output.