friends. I have this code in my python application:
if '(' in obj.value or ')' in obj.value:
city, country = obj.value.upper()[:-1].split('(')
found = city.strip() == self.customer.city.upper() and country == self.customer.country.upper()
else:
city = obj.value.upper()
found = city.strip() == self.customer.city.upper()
A text string that can be with the following possible values:
'New York' or 'New York (NY)'
But the problem is that the code below does not guarantee a possible error, for example, be missing one of the brackets. Eg
'New York NY)'
How can I improve and protect this little snippet? There is a formula in Regex, for example? (I know some regex)