1# Python3 program to demonstrate the use of
2# strip() method
3
4string = " python strip method test "
5
6# prints the string without stripping
7print(string)
8
9# prints the string by removing leading and trailing whitespaces
10print(string.strip())
11
12# prints the string by removing strip
13print(string.strip(' strip'))
14Output:
15 python strip method test
16python strip method test
17python method test
1txt = " test "
2
3txt.strip()
4#Output: "test"
5
6txt.lstrip()
7#Output: "test "
8
9txt.rstrip()
10#Output: " test"
1txt = ",,,,,rrttgg.....banana....rrr"
2x = txt.strip(",.grt")
3#outputs banana
4print(x)