1. Home
  2. Data Science
  3. Python
  4. Which special method makes len(obj) work in Python?

Added 25 Nov 2026

Which special method makes len(obj) work in Python?

  1. __size__
  2. __length__
  3. __count__
  4. __len__ Correct answer

Correct answer

D. __len__

MCQSEXAM

Explanation

Defining __len__ lets objects work with len().

Reference

Asked in: Python Interview OOP

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