By default, Python’s .strip()
method removes whitespace characters from both ends of a string. To remove different characters, you can pass a string as an argument that specifies a set of characters to remove. The .strip()
method is useful for tasks like cleaning user input, standardizing filenames, and preparing data for storage.
By the end of this video course, you’ll understand that:
- The
.strip()
method removes leading and trailing whitespace but doesn’t remove whitespace from the middle of a string. - You can use
.strip()
to remove specified characters from both ends of the string by providing these characters as an argument. - With the related methods
.lstrip()
and.rstrip()
, you can remove characters from one side of the string only. - All three methods,
.strip()
,.lstrip()
, and.rstrip()
, remove character sets, not sequences. - You can use
.removeprefix()
and.removesuffix()
to strip character sequences from the start or end of a string.
What’s Included:
- 8 Lessons
- Video Subtitles and Full Transcripts
- 2 Downloadable Resources
- Accompanying Text-Based Tutorial
- Interactive Quiz to Check Your Progress
- Q&A With Python Experts: Ask a Question
- Certificate of Completion
Downloadable Resources:
Related Learning Paths: