Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pro = {
- "A":"Newfoundland",
- "B":"Nova Scotia",
- "C":"Prince Edward Island",
- "E": "New Brunswick",
- "G":"Quebec",
- "H":"Quebec",
- "J":"Quebec",
- "K":"Ontario",
- "L":"Ontario",
- "M":"Ontario",
- "N":"Ontario",
- "P":"Ontario",
- "R":"Manitoba",
- "S":"Saskatchewan",
- "T":"Alberta",
- "V":"British Columbia",
- "X": ["Nunavut", "Northwest Territories"],
- "Y":"Yukon"
- }
- while True:
- zip = input("Please enter the zip code: ")
- if zip == "":
- break
- if len(zip) != 7 or zip[0] not in pro:
- print("Invalid Zip Code!!! Please enter the correct one.")
- else:
- province = pro[zip[0]]
- if zip[0] == "X":
- province = "Nunavut or Northwest Territories"
- if zip[1] == "0":
- city = "rural"
- else:
- city = "urban"
- print(f'The address is an {city} one in {province}.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement