rstrip() function in python by R4R Team

- rstrip() is a python in-build function which are used to delete the specified content at the right side of the string
- it take one string as an argument which we want to remove from the right portion of the given string.

Syntax-

str.rstrip(chars)

Example

string is s="this is string"
and s.rstrip("string") will return "this is"


program-

s="This is string"
print(s.rstrip('string'))
s="11111111111mgs"
print(s.lstrip('mgs'))
s="-----this is string-------"
print(s.rstrip("-"))
s="-----this is string-------"
print(s.lstrip("this"))


output-

This is
11111111111mgs
-----this is string
-----this is string-------


-In this program, we operate rstrip() function on different strings in the above program and remove the right side of string and print them.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!