1#!/usr/bin/python
2
3str = " this is string example....wow!!! ";
4print str.rstrip()
5str = "88888888this is string example....wow!!!8888888";
6print str.rstrip('8')
7
8#the answer
9
10#this is string example....wow!!!
11#88888888this is string example....wow!!!
1# Only trailing whitespaces are removed
2text1 = ' Python Programming '
3print(text1.rstrip())
4
5
6# Remove the whitespace and specified character at
7# trailing end
8text2 = ' code its my code '
9print(text2.rstrip(' code'))
10
11# Remove the specified character at
12# trailing end
13text3 = 'code its my code'
14print(text3.rstrip('code'))
1#python3 program of rstrip method with optional argument
2s = "Hello There "
3a = "s"
4print(s.rstrip()) # prints s without any spaces at the end
5print(s.rstrip(a)) # prints s without any characters of value a at the end