I\'m new to python and I was wondering how string comparison is done
Let\'s say I have a list of strings containing state names like
states = [\"New York
Here's another alternative answer using a regexp:
import re states = ["New York", "California", "Nebraska", "Idaho"] pattern = re.compile(r'.*(' + r'|'.join(states) + ').*') postal_addr = "1234 1st E St San Jose California 95112" match = pattern.match(postal_addr) if match: state = match.group(1)