The problem might lie at
if state != state2.get:
The above code is checking value of string to that of inbuilt function since state2.get
is an inbuilt function. This always evaluates to True since string is never equal to function and hence exiting the program.
You might better off be using
if state in state2.values():
state2.values()
gives only the values of dictionary
And since you said you want to make sure the state entered is 2 characters, you can use len()
as you used with zipc.
if len(state)!=2:
Furthur more, it seems that the full form of states aren't being used anywhere, if you only want to make sure that entered state is from valid list of states then you can just create a list having abbrevations of all the valid states and check whether entered input is in the list.
state2=['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY']
if state not in state2:
sys.exit()