In my example I want to access all the albums that coldplay has. this is the json. I understand that with the requests library I transform it into a dictionary but I cannot access the albums but it returns the value of each position in the topalbums element https://jsoneditoronline.org/?id=c8de55785bbb400cb34c62d519e2962d
import requests
import json
r = requests.get('http://ws.audioscrobbler.com/2.0/?method=artist.gettopalbums&artist=coldplay&api_key=a31007b9178e35854f9fa22039cb7362&format=json')
musica_dict = json.loads(r.text)
print type(musica_dict)
for item in musica_dict:
for album in item:
print album
Your music_dict object is a dictionary, it contains a topalbums key , and if you access music_dict['topalbums'] it's also a dictionary that has two keys, album and @attr .
musica_dict['topalbums']['album'] is a list (which you can iterate over), each element of this list is a dictionary containing the keys 'name', 'playcount', 'mbid', 'url', 'artist ', 'image' .
So to print the information it would be as follows: