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]))

  1. A.

    3

  2. B.

    2

  3. C.

    4

  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.

Explore the full course: Rssb Senior Computer Instructor