The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #356
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)
What is the output of the code snippet below?
— The Python Quiz (@thepythonquiz) December 22, 2020
x = [i for i in range(1, 10, 2)]
print(x)
[1, 3, 5, 7, 9]
[1, 2, 6, 8, 10]
It will throw a ValueError error.
[]#python #python3 #pythonprogramming #learnpython
Question difficulty: π΅π΅π΅π΅π΅