Advertisement
biswasrohit20

two

Mar 29th, 2021
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. pro = {
  2. "A":"Newfoundland",
  3. "B":"Nova Scotia",
  4. "C":"Prince Edward Island",
  5. "E": "New Brunswick",
  6. "G":"Quebec",
  7. "H":"Quebec",
  8. "J":"Quebec",
  9. "K":"Ontario",
  10. "L":"Ontario",
  11. "M":"Ontario",
  12. "N":"Ontario",
  13. "P":"Ontario",
  14. "R":"Manitoba",
  15. "S":"Saskatchewan",
  16. "T":"Alberta",
  17. "V":"British Columbia",
  18. "X": ["Nunavut", "Northwest Territories"],
  19. "Y":"Yukon"
  20. }
  21.  
  22. while True:
  23. zip = input("Please enter the zip code: ")
  24. if zip == "":
  25. break
  26. if len(zip) != 7 or zip[0] not in pro:
  27. print("Invalid Zip Code!!! Please enter the correct one.")
  28. else:
  29. province = pro[zip[0]]
  30. if zip[0] == "X":
  31. province = "Nunavut or Northwest Territories"
  32. if zip[1] == "0":
  33. city = "rural"
  34. else:
  35. city = "urban"
  36. print(f'The address is an {city} one in {province}.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement