How to remove the last character from a string in Python