What will be the output of the following Python function? print(len(['PM', 2,…
2026
What will be the output of the following Python function?
print(len(['PM', 2, False]))
- A.
3
- B.
2
- C.
4
- D.
Error
Attempted by 198 students.
Show answer & explanation
Correct answer: A
The len() function returns the count of items in a list. The provided list ['PM', 2, False] contains three elements: a string, an integer, and a boolean. Each element counts as one item regardless of its data type, so the output is 3.