What is the output of print([x for x in range(5) if x % 2 == 0]) in Python?
print([x for x in range(5) if x % 2 == 0])
Correct answer
A. [0, 2, 4]
6 views
A. [0, 2, 4]
6 views
A condition at the end of a comprehension filters items.
Asked in: Python Interview Advanced Python
https://docs.python.org/3/library/index.htmlNot sure why the answer is A? Ask here and get an explanation.