how to strip characters in python

29

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.

Comments

Submit
0 Comments