# How to remove all trailing whitespace of string in Python?

We can use the method rstrip() which returns a copy of the string in which all specified chars have been stripped from the end of the string. The default char to be trimmed is whitespace. For example:

>>> '   Hello   '.rstrip()
'   Hello'
>>> 'Ninja Turtles the movie     '.rstrip()
'Ninja Turtles the movie'