str.rstrip('characters')
'characters' is optional
str = 'Hey there\n'
new_str = str.rstrip('\n')
print(new_str)
>>>Hey there
str = 'Hey there '
new_str = str.rstrip()
print(new_str)
>>>Hey there
str = 'heeyyyyyy'
new_str = str.rstrip('ye')
print(new_str)
>>>h
Also read: strip() method and lstrip() method