Fill in the code to check if the text passed includes a possible U.S. zip code code example
Example 1: def check_zip_code(text): result = re.search(r'\d{5}(?:-\d{4})?', text) return result != None
import re
def check_zip_code (text):
m = re.search(r'(?!\A)\b\d{5}(?:-\d{4})?\b', text)
return True if m else False
print(check_zip_code("The zip codes for New York are 10001 thru 11104."))
print(check_zip_code("90210 is a TV show"))
print(check_zip_code("Their address is: 123 Main Street, Anytown, AZ 85258-0001."))
print(check_zip_code("The Parliament of Canada is at 111 Wellington St, Ottawa, ON K1A0A9."))
Example 2: def check_zip_code(text): result = re.search(r'\d{5}(?:-\d{4})?', text) return result != None
(?!\A)\b\d{5}(?:-\d{4})?\b