Python-Quizzes | Python List Quiz | Question 20
Find the output of the following program:
Python3
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)
|
(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
Please comment below if you find anything wrong in the above post
Last Updated :
17 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...