Question #356

What is the output of the code snippet below?
x = [i for i in range(1, 10, 2)]
print(x)

Generator expressions provide an additional shortcut to build generators out of expressions, similar to that of list comprehensions. In fact, a list comprehension can be turned into a generator expression by replacing the square brackets ([] ) with parentheses. Alternately, lists comprehensions cam be thought of generator expressions wrapped in a list constructor. (wiki.python.org/moin/Generators)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵