Python Project: Weather Forecast API

The code below connects with National Weather Service api and returns the current forecast for your zone.

import requests

#ask for zone, have ILZ as default
#Show info for the zone
#ask for new zone
#repeat until y/n is not

while True:
  try:
    zone = input("Enter a zone: " )

    #zone and weather api link
    if zone == '':
      zone = 'ILZ103'
    url = 'https://api.weather.gov/zones/forecast/' + zone + '/forecast'


    response = requests.get(url)
    forecast = response.json()['properties']

    #print(forecast.keys())

    print("Zone: " + forecast['zone'])
    print(' ')

    for period in forecast['periods']:
      print(period.get('name'))
      print(period.get('detailedForecast'))
      print(' ')

    again = input("Try again? y/n: ").strip().lower()
    if again != 'y':
      break

  except KeyError: 
    print("Enter a correct zone number.")

zone list: https://alerts.weather.gov/cap/il.php?x=2
inspired by: https://justinbraun.com/python-101-pulling-the-weather-forecast-with-the-nws-api/