adplus-dvertising
frame-decoration

Question

What is the output of the code shown?
l=[1,2,3,4,5]
[x&1 for x in l]

a.

[1, 1, 1, 1, 1]

b.

[1, 0, 1, 0, 1]

c.

[1, 0, 0, 0, 0]

d.

[0, 1, 0, 1, 0]

Posted under Python

Answer: (b).[1, 0, 1, 0, 1]

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the code shown?