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:
- Remove the leading and trailing whitespace and newline characters from a string: strip()
- Remove specified characters from the left side of a string: lstrip()
- Remove specified characters from the right side of a string: rstrip()
- Remove specified characters from both ends of a string: strip(‘specified characters’)
- Remove specified characters from the left end of the string: lstrip(‘specified characters’)
- Remove specified characters from the right end of a string: rstrip(‘specified character’)