Python-Quizzes | Python List Quiz | Question 20
Question 20: Find the output of the following program:
data = [x for x in (x for x in 'Geeks 22966 for Geeks' if x.isdigit()) if (x in ([x for x in range ( 20 )]))] print (data) |
chevron_right
filter_none
(A) [2, 2, 9, 6, 6]
(B) [ ]
(C) Compilation error
(D) Runtime error
Answer: (B)
Explanation: Since here x has not been converted to int, the condition in the if statement fails and therefore, the list remains empty.
Quiz of this Question