Question Detail

COS 102 Python strings Objective Question

Question

What is the primary purpose of the len() function when used with a string in Python?
Options
A To check if a string is empty.
B To convert a string to an integer.
C To count the total number of characters in a string.
Correct Answer
D To remove spaces from a string.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 8, under 'Measuring Text', defines it: 'The len() function counts the number of characters in a string.'

Hint

The name 'len' is short for what common measurement term?

Question Info