This is part of my code. The API provides a JSON file that includes an empty value (null) in one location. I get TypeError: 'NoneType' object is not subscriptable on the line that appends. I've read about a number of methods to deal with this (I want my program to just ignore the null value, or replace it with 0 or 'n/a' or whatever, but continue, not break) but they contain insufficient instruction - I still need a lot hand-holding, I'm afraid.
import requests
all_data = []
api_url = 'https://api.nfz.gov.pl/app-umw-api/agreements?page={}&limit=25&format=json&api-version=1.2&serviceType=03&year=2017&branch=07'
for page in range(0, 17):
data = requests.get(api_url.format(page)).json()
for a in data["data"]["agreements"]:
all_data.append({**a["attributes"], "link": a["links"]['related']})
print(all_data)