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"
Exercise 4-d: Lstrip method to remove from the left side only
Using a combination of .split() and .lstrip() methods, get the word "Derivatives".