I have a for loop that is going through a dictionary with a lot of nested dictionaries. When the loop gets to an entry that doesn't have the key I am looking for it stops. How do I make it keep going through all the rest of the data?
In my code the loop goes through the games fine. When I try to get all the game['odds'] the loop stops if one game doesn't have an odds key which ends up giving me a key error and only printing out the first four games.
results = requests.request("GET", url, headers=headers).json()
games = results['results']
for game in games:
spread = game['odds']
for line in spread:
points = line['spread']['current']['home']
print(points)