To remove white spaces from the end of a string, one can use the rstrip() method.
Here is a code snippet showing how to use it:
main.py139 chars8 lines
In this example, rstrip() removes the white spaces at the end of the string my_str, and the output is " hello world!".
gistlibby LogSnag