adplus-dvertising
frame-decoration

Question

Write the list comprehension to pick out only negative integers from a given list ‘l’.

a.

[x<0 in l]

b.

[x for x<0 in l]

c.

[x in l for x<0]

d.

[x for x in l if x<0]

Posted under Python

Answer: (d).[x for x in l if x<0]

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Write the list comprehension to pick out only negative integers from a given list ‘l’.