1. Home
  2. Data Science
  3. Python
  4. Which Python function removes whitespace from string ends?

Added 16 Sep 2025

Which Python function removes whitespace from string ends?

  1. trim()
  2. strip() Correct answer
  3. clean()
  4. remove()

Correct answer

B. strip()

13 views

MCQSEXAM

Explanation

The strip() method returns a copy of the string with leading and trailing whitespace removed.

Reference

Asked in: GATE CS, UGC NET

https://docs.python.org/3/library/stdtypes.html#str.strip

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? 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