Search notes:

Python: string.rstrip()

rstrip(char_set) removes all characters in char_set from the right side of a string:
#!/usr/bin/python3

txt  = 'msd45q63v742'

#
#  Remove all digits from the right side:
#
txt_ =  txt.rstrip('0123456789')

print(txt_) # msd45q63v
Github repository about-python, path: /built-in/types/str/rstrip.py
A specific use of rstrip is to remove line breaks from a string's end: rstrip('\n\r'). This is especially useful when the strings are read by iterating over each line in a file. This somewhat imitates the chomp() function in Perl.

See also

The last n characters can be removed from a string with str = str[:-n] (See extracting substrings from strings).
Remove last n characters from a string
str

Index