1. Home
  2. Data Science
  3. Python
  4. What is the time complexity of the in operator on a list…

Added 25 Nov 2026

What is the time complexity of the in operator on a list in Python?

  1. O(1)
  2. O(log n)
  3. O(n^2)
  4. O(n) Correct answer

Correct answer

D. O(n)

6 views

MCQSEXAM

Explanation

Membership testing scans the list linearly, unlike sets and dicts which average O(1).

Reference

Asked in: Python Interview Lists

https://docs.python.org/3/tutorial/datastructures.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