What is the output of print([x for x in [1, 2, 3] if x > 1]) in Python?
print([x for x in [1, 2, 3] if x > 1])
Correct answer
A. [2, 3]
A. [2, 3]
Filtering a list with a comprehension and a condition.
Asked in: Python Interview Lists
https://docs.python.org/3/tutorial/datastructures.htmlNot sure why the answer is A? Ask here and get an explanation.