Question Detail

COS 102 Advanced Text Processing Objective Question

Question

What does the `.strip()` string method primarily do?
Options
A Removes all characters from the string.
B Removes leading and trailing whitespaces.
Correct Answer
C Removes only leading whitespaces.
D Removes only trailing whitespaces.
Correct Answer

Option B is the correct answer.

Detailed Explanation

The document's 'Essential String Methods' table defines .strip() as: 'Removes leading/trailing whitespaces.'

Hint

The example `" x ".strip() → "x"` demonstrates its function.

Question Info