Question Detail

COS 102 Python strings Objective Question

Question

What is the result of len("Python 3") in Python?
Options
A 6
B 7
C 8
Correct Answer
D 9
Correct Answer

Option C is the correct answer.

Detailed Explanation

The string "Python 3" contains 6 letters, 1 space, and 1 digit, totaling 8 characters. The len() function counts all characters, including spaces (page 8, 11).

Hint

Count every single character, including spaces, within the quotes.

Question Info