s = 'This is a sentence with unwanted characters.AAAAAAAA' print('Strip unwanted characters: {}'.format(s.rstrip('A'))) # Output # Strip unwanted characters: This is a sentence with unwanted characters.