rstrip method code in python code example
Example 1: rstrip in python
text = " Apple "
x = txt.rstrip()
>>> ' Apple'
x.rstrip('e')
>>> ' Appl'
x.lstrip()
>>> 'Apple'
Example 2: rstrip python3
#python3 program of rstrip method with optional argument
s = "Hello There "
a = "s"
print(s.rstrip()) # prints s without any spaces at the end
print(s.rstrip(a)) # prints s without any characters of value a at the end