I have the following code:
url = 'abcdc.com'
print(url.strip('.com'))
I expected: abcdc
I got: abcd
Now I do
url.rsplit('.com', 1)
Is there a better way?
See How do the .strip/.rstrip/.lstrip string methods work in Python? for a specific explanation of what the first attempt is doing.