1. Home
  2. Data Science
  3. Python
  4. What does the strip() method do in Python?

Added 25 Nov 2026

What does the strip() method do in Python?

  1. Removes all spaces
  2. Splits a string
  3. Converts to lowercase
  4. Removes leading and trailing whitespace Correct answer

Correct answer

D. Removes leading and trailing whitespace

5 views

MCQSEXAM

Explanation

strip() removes whitespace (or specified characters) from both ends of a string.

Reference

Asked in: Python Interview Strings

https://docs.python.org/3/library/stdtypes.html#string-methods

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs