Strip trailing spaces : rstrip « String « Python Tutorial






import string
badSentence = "\t\tThis sentence has problems.   "


#Strip trailing spaces
print "Length = " + str(len(badSentence))
print "Without trailing spaces = " + str(len(badSentence.rstrip(' ')))








5.28.rstrip
5.28.1.Strip trailing spaces