I am a bit confused as to how access artists
name in this JSON result:
{
\"tracks\" : {
\"href\" : \"https://api.spotify.com/
Defensively written, this might look something like:
artist_names = set() # using a set avoids adding the same name more than once
if 'tracks' in results and 'items' in results['tracks']:
for item in results['tracks']['items']:
for artist in item.get('artists', ()):
if 'name' in artist:
artist_names.add(artist['name'])
for name in artist_names:
print "Found artist:", name