how to match last char in string in python