I'm fetching data from an API and converting the JSON using requests
, then extracting one value from each dict in a list within a dict:
response = requests.get("http://api.open-notify.org/astros.json")
astros = response.json()
print(astros["number"])
[print(astronaut['name']) for astronaut in astros['people']]
The output gives the list of names, as desired, but follows this with a list of 6 None values; I can't see why.