What does the len() function return in Python?
Correct answer
B. Length of a list
15 views
B. Length of a list
15 views
len() returns the number of items in an object — for example the length of a list: len([1, 2, 3]) gives 3.
The same function also works on strings, tuples, dictionaries and sets, returning the character or element count. It runs in constant time because Python containers store their size.
Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.