The rstrip() method removes trailing whitespace or specified characters from the end of a string, often used in data cleaning tasks to ensure consistency in string formatting.
Syntax
string.rstrip([chars])
-chars (optional): Specifies characters to remove from the end. Defaults to whitespace if omitted.
my_str='Plus2net '
output=my_str.rstrip()
print(output)
my_str='plus2net**'
output=my_str.rstrip('*')
print(output) # removes * from right
my_str='plus2net *#*#'
output=my_str.rstrip('*#')
print(output) # removes all right