strip string method in Python

The strip() method in Python removes or truncates the given characters from the beginning and the end of the original string.

The default behavior of the strip() method is to remove the whitespace from the beginning and at the end of the string.

Example 1:

str = "    hello Dmitri     "
print(str.strip())
Output 1:
hello Dmitri
Example 2:
str = "------hello Dmitri--------"
print(str.strip("-"))
Output 2:
hello Dmitri