Q. 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]
πŸ’¬ Discuss
βœ… Correct Answer: (D) [x for x in l if x<0]
Explanation: to pick out only the negative numbers from a given list ‘l’, the correct list comprehension statement would be: [x for x in l if x<0].

Explanation by: Mr. Dubey
to pick out only the negative numbers from a given list ‘l’, the correct list comprehension statement would be: [x for x in l if x<0].

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
1006
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
84%
Success Rate