Python Code Challenge: Generators

 ❓ Can you guess the output of this Python code?


def infinite_numbers():

    num = 1

    while True:

        yield num

        num += 1


gen = infinite_numbers()

print(next(gen))

print(next(gen))

print(next(gen))


🤔 Think you know the answer? Vote below!


📚 Want to master Generators in Python?

🔗Click the link to read the full article!

https://yasirbhutta.github.io/python/posts/generators-in-python.html


Options:

A) 1 1 1

B) 1 2 3

C) 

Infinite loop

D) Error

Post a Comment

Previous Post Next Post