Answers for "rstrip in python"

7

what is r strip function in python

#!/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!!!
Posted by: Guest on May-30-2020
5

rstrip in python

text = "     Apple      "
x = txt.rstrip()
>>> '     Apple'
x.rstrip('e')
>>> '  Appl'
x.lstrip()
>>> 'Apple'
Posted by: Guest on March-09-2021
1

rstrip python

text = "   hello   "

text = text.lstrip() # lstrip == left strip
>>> '   hello' 

text = text.rstrip() # rstrip == right strip
>>> 'hello   '

text = text.strip() # strip == strip from both sides
>>> 'hello'
Posted by: Guest on August-22-2021
0

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
Posted by: Guest on August-22-2020
-1

rstrip python

txt = "     banana     "

x = 
    txt.rstrip()


    print("of all fruits", x, "is my favorite")
Posted by: Guest on February-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language