Python Strip Exercises
Let’s check out some exercises that will help understand .strip() method better.
Exercise 4-a: Strip method to remove whitespace on both sides
Use strip method to strip the whitespaces on both sides of the string.
Exercise 4-b: Strip method to remove specific characters from a string
Using .strip() method, strip the string so that, only "Babylon" remains.
Exercise 4-c: Rstrip method to remove from the right side only
Let's say you created a program that crawls websites online and it returned a string with a bunch of unnecessary characters on the right side. Using .rstrip() method, strip the characters from the right side of the string only so, in the end you get: "@Bloomberg"
Need More Exercises?
Check out Holy Python AI+ for amazing Python learning tools.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.
*Includes 14 more programming languages, inspirational tools and 1-on-1 consulting options.

Umut Sagir
Finance & Data Science Professional,
Founder of HolyPython
Founder of HolyPython