The method rstrip() returns a copy of the string in which all chars have been stripped from the end of the string (default whitespace characters).
The syntax of the method is: str.lstrip([chars])
Below is the python program to demonstrate the rstrip() function:
str = "The Best Learning Resource for Online Education"; print (str.rstrip()) str = "####The Best Learning Resource for Online Education####"; print (str.rstrip('#'))
When we run above the program, the outcome is as follows:
The Best Learning Resource for Online Education
####The Best Learning Resource for Online Education
Below are several other functions that we can use to work with string in Python 3