rstrip python3
#!/usr/bin/python
str = " this is string example....wow!!! ";
print str.rstrip()
str = "88888888this is string example....wow!!!8888888";
print str.rstrip('8')
#the answer
#this is string example....wow!!!
#88888888this is string example....wow!!!
3.8
10
txt = " banana "
x =
txt.rstrip()
print("of all fruits", x, "is my favorite")
Thank you!
10
0
4
2
text = " Apple "
x = txt.rstrip()
>>> ' Apple'
x.rstrip('e')
>>> ' Appl'
x.lstrip()
>>> 'Apple'
Thank you!
2
0
0
1
#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
Thank you!
1
0
Are there any code examples left?
New code examples in category Python