Two instances of the same generator

Report a typo

Consider the following piece of code:

def my_generator():
    i = 0
    while True:
        yield i
        i = i + 1

gen_1 = my_generator()
print(next(gen_1))
print(next(gen_1))

gen_2 = my_generator()
print(next(gen_2))

print(next(gen_1))

Which output would you see on the screen?

Select one option from the list
___

Create a free account to access the full topic