Reputation: 42023
Example:
string1 = 'title--'
string2 = 'title-'
string3 = 'this-is-a-title----'
>> print doSomething(string1)
>> title
>> print doSomething(string2)
>> title
>> print doSomething(string3)
>> this-is-a-title
Upvotes: 3
Views: 2334
Reputation: 601471
string1.rstrip("-")
# "title"
string2.rstrip("-")
# "title"
string3.rstrip("-")
# "title-is-a-title"
Upvotes: 10