Strip trailing whitespaces from string [Python]

If you want to remove extra whitespaces from start and end of a string, use strip() method in Python. strip() method removes all default whitespaces (spaces and tabs \t) and returns the copy of the string.

Python code to strip trailing whitespaces from string

Note: Code works in both Python 2 and 3

Output on Windows PowerShell

strip-trailing-white-spaces-Python-code