What will be the output of the following Python code?

g = (i for i in range(5))
type(g)

a) class <’loop’>
b) class <‘iteration’>
c) class <’range’>
d) class <’generator’>

1 thought on “What will be the output of the following Python code?”

  1. d
    Explanation: Another way of creating a generator is to use parenthesis. Hence the output of the code shown above is: class.

Leave a Comment