Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python-Quizzes | Python List Quiz | Question 17

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Find the output of the following program: 

Python3




data = [x for x in range(5)]
temp = [x for x in range(7) if x in data and x%2==0]
print(temp)

(A)

[0, 2, 4, 6]

(B)

[0, 2, 4]

(C)

[0, 1, 2, 3, 4, 5]

(D)

Runtime error


Answer: (B)

Explanation:

This statement checks whether the value lies in list data and if it does whether it’s divisible by 2. It does so for x in (0, 7).


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 17 Sep, 2020
Like Article
Save Article
Similar Reads