Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Loop over a JSON not picking up all values

I am trying to return each highlight’s ‘blurb’ and ‘FLASH_1800K_896x504’ url. To do this, I am running this loop below:

import requests
game_url = "http://statsapi.web.nhl.com/api/v1/game/2021030321/content"
team_response = requests.get(game_url)
js = team_response.json()
newdata = js['highlights']['gameCenter']['items']
for item in newdata:
    print(item['blurb'])
    print(item['playbacks'][3]['url'])

After doing a Ctrl-F on the data file, I am expecting 51 results. However, only 15 are being returned. Am I missing something obvious?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

seems like not all occurence of "FLASH_1800K_896x504" exist in the path that you’re logging, try exploring futher more your json file

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading