What is Python Strip?
The strip() function is part of the built-in function available in python. The function will remove given characters from the start and end of the original string.
By default, function strip() will remove white spaces from the start and end of the string and return the same string without white spaces.
In this Python tutorial, you will learn:
- characters : (optional) The given characters will be removed from the start or end of the original string.
- If the characters parameter is not given, the whitespaces from the start and end of the string will be removed.
The strip() will return:
- The original string with white spaces removed from the start and end if the characters to be removed are not specified.
- In case the string does not have any whitespaces at the start or end, the string will be returned as it is and will match with the original string.
- If the characters parameter is given, and if the characters are given matches, the characters at the start or end of the string will be removed from the original string, and the rest of the string will be returned.
- Incase if the characters given does not match the start or the end in the original string, the string will be returned as it is.