1. Home
  2. Data Science
  3. Python
  4. What is the output of print(len(max(['a', 'abc', 'ab']…

Added 25 Nov 2026

What is the output of print(len(max(['a', 'abc', 'ab'], key=len))) in Python?

print(len(max(['a', 'abc', 'ab'], key=len)))
  1. 1
  2. 3 Correct answer
  3. 2
  4. Error

Correct answer

B. 3

6 views

MCQSEXAM

Explanation

max with key=len picks the longest item.

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 B? 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