Nothing Runs Until You Ask

def counter():
    print("generator body starting")
    total = 0
    for i in range(3):
        total += i
        yield total

print("before call")
g = counter()
print("after call, before first next")
print(next(g))
print(next(g))

What is the order of printed output?

A

generator body starting, before call, after call, before first next, 0, 1

B

before call, after call, before first next, generator body starting, 0, 1

C

before call, generator body starting, after call, before first next, 0, 1

D

before call, after call, before first next, generator body starting, 0, generator body starting, 1