LearnFrenzy
Sign in Take a free test

Lists · Predict the Output · Question 14

Comparing lists Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 14 Back to Exercise

What is the output of the following Python program?

main.py
print([1, 2] == [2, 1], [1, 2, 3] < [1, 3], [] < [0], [2] > [1, 9, 9])
  • A True True True False
  • B False False True False
  • C False True True True Correct
  • D False True False True
Correct Answer: Option C

Lists compare item by item: order matters for ==; 2 < 3 decides [1, 2, 3] < [1, 3]; an empty list is smaller than any non-empty one; 2 > 1 decides the last.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links