Python-Quizzes | Python List Quiz | Question 20

Question 20: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

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


(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

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.