1. Home
  2. Data Science
  3. Python
  4. What is the output of print([1, 2] == [1, 2]) in Python?

Added 25 Nov 2026

What is the output of print([1, 2] == [1, 2]) in Python?

print([1, 2] == [1, 2])
  1. False
  2. Error
  3. None
  4. True Correct answer

Correct answer

D. True

7 views

MCQSEXAM

Explanation

The == operator compares the values inside two objects, and both lists hold the same items in the same order, so the result is True. A useful fact to remember is that == checks equality of values, while the "is" operator checks whether two names point to the very same object, so [1, 2] is [1, 2] would give False. Option A (False) is wrong because the contents and order of both lists match exactly. Option B (Error) is wrong because comparing two lists with == is perfectly valid Python. Option C (None) is wrong because a comparison always returns a Boolean value, either True or False, and never None.

Reference

Asked in: Python Interview Data Types

https://docs.python.org/3/library/stdtypes.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs