What are the functionalities of the strip function in Python?

The strip function is used to remove specific characters from both ends of a string (default is whitespace and newline characters).

The function of the strip function includes:

  1. Remove the leading and trailing whitespace and newline characters from a string: strip()
  2. Remove specified characters from the left side of a string: lstrip()
  3. Remove specified characters from the right side of a string: rstrip()
  4. Remove specified characters from both ends of a string: strip(‘specified characters’)
  5. Remove specified characters from the left end of the string: lstrip(‘specified characters’)
  6. Remove specified characters from the right end of a string: rstrip(‘specified character’)
bannerAds