Question Detail

COS 102 Python strings Objective Question

Question

What is the output of the Python expression len("Python 3")?
Options
A 8
Correct Answer
B 7
C 6
D Error
Correct Answer

Option A is the correct answer.

Detailed Explanation

The len() function counts all characters, including spaces. 'P' 'y' 't' 'h' 'o' 'n' ' ' '3' are 8 characters in total.

Hint

Count every character, including the space between 'Python' and '3'.

Question Info