In [1]:
#1) With "Lil Wayne" and "Lil Kim" there are a lot of "Lil" musicians. 
#Do a search and print a list of 50 that are playable in the USA 
#(or the country of your choice), along with their popularity score.

In [2]:
import requests

In [3]:
response = requests.get('https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=50')

& for multiple parameters


In [4]:
data = response.json()

In [5]:
data.keys()


Out[5]:
dict_keys(['artists'])

In [6]:
artist_data = data['artists']

In [7]:
artist_data.keys()


Out[7]:
dict_keys(['previous', 'total', 'offset', 'items', 'href', 'next', 'limit'])

In [8]:
lil_names = artist_data['items']
#lil_names = list of dictionaries = list of artist name, popularity, type, genres etc

2) What genres are most represented in the search results?

Edit your previous printout to also display a list of their genres in the format GENRE_1, GENRE_2, GENRE_3". If there are no genres, print "No genres listed". Tip: "how to join a list Python" might be a helpful search


In [9]:
for names in lil_names:
    if not names['genres']:
        print(names['name'], names['popularity'], "there are no genres listed")
    else:
        print(names['name'], names['popularity'], names["genres"])

#Join all the lists of genres in the dictionary and then count the number of elements in it


Lil Wayne 86 ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Lil Yachty 74 there are no genres listed
Lil Uzi Vert 74 there are no genres listed
Lil Dicky 69 there are no genres listed
Boosie Badazz 67 there are no genres listed
Lil Jon 72 ['crunk', 'dirty south rap', 'southern hip hop']
King Lil G 61 there are no genres listed
Lil Durk 60 there are no genres listed
Lil Jon & The East Side Boyz 60 there are no genres listed
Lil Bibby 54 there are no genres listed
G Herbo 53 there are no genres listed
Lil Rob 50 ['chicano rap', 'latin hip hop']
Lil Reese 50 there are no genres listed
Lil Scrappy 50 ['crunk', 'dirty south rap', 'southern hip hop', 'trap music']
Bow Wow 57 ['hip pop', 'pop rap']
Lil Keke 48 there are no genres listed
Lil Wyte 50 ['juggalo']
Lil Blood 46 there are no genres listed
Lil Snupe 45 there are no genres listed
Lil Mama 45 ['hip pop']
Lil Boom 46 there are no genres listed
Lil B 44 there are no genres listed
Lil' Kim 62 ['hip pop']
Lil Cuete 40 ['chicano rap']
Lil Phat 40 there are no genres listed
Lil Debbie 43 there are no genres listed
Lil Twist 40 ['jerk']
Lil Trill 37 ['deep trap']
Lil Goofy 36 there are no genres listed
Lil Lonnie 37 there are no genres listed
Lil AJ 37 there are no genres listed
Lil Haiti 38 there are no genres listed
Lil Cray 36 there are no genres listed
Lil Twon 36 there are no genres listed
Mr. Lil One 36 ['chicano rap']
Lil Mouse 35 there are no genres listed
Lil Silva 43 there are no genres listed
Lil Yase 34 there are no genres listed
Lil Flash 38 there are no genres listed
Lil Suzy 34 ['freestyle']
Lil Eddie 41 there are no genres listed
Lil Rue 34 there are no genres listed
Lil Kesh 39 there are no genres listed
Lil Wayne, DJ Drama 35 there are no genres listed
Lil C 33 there are no genres listed
Lil Rick 39 ['soca']
Lil E 35 there are no genres listed
Lil June 32 there are no genres listed
Lil Fate 34 there are no genres listed
Lil' Flip 50 ['crunk', 'dirty south rap']

ANSWER: for artist in artists: print(artist['name'], artist['popularity']) if len(artist['genres']) > 0: genres = ", ".join(artist['genres']) print("Genre list: ", genres else: print("No genres listed")

              OR
    if len(artist['name']) == 0:

              OR
    if not len(artist['genres']) == 0:


"-".join(your_list) to join lists


In [17]:
#ANSWER:
all_genres = []    
    
for artist in lil_names:
    print("All genres we've heard of:", all_genres)
    #The conditional: None
    print("Current artist has:", artist['genres'])
    all_genres = all_genres + artist['genres']

    #genre_list = ", ".join(artist['genres'])
    #print(artist['name'], ":", genre_list)

    all_genres.count('dirty soup rap')
    all_genres.count('crunk')

#This is bad because dirty south rap shows up four times. We need a unique list of genres
    for genre in all_genres:
        genre_count = all_genres.count(genre)
        print(genre, "shows up", genre_count, "times")

#To remove duplicates. You need to turn a list into a set.
unique_genres = set(list_with_duplicates)
for genre in unique_genres:
    genre_count = all_genres.count(genre)
    print(genre, "shows up", genre_count, "times")


All genres we've heard of: []
Current artist has: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
dirty south rap shows up 1 times
pop rap shows up 1 times
southern hip hop shows up 1 times
trap music shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
dirty south rap shows up 1 times
pop rap shows up 1 times
southern hip hop shows up 1 times
trap music shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
dirty south rap shows up 1 times
pop rap shows up 1 times
southern hip hop shows up 1 times
trap music shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
dirty south rap shows up 1 times
pop rap shows up 1 times
southern hip hop shows up 1 times
trap music shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
dirty south rap shows up 1 times
pop rap shows up 1 times
southern hip hop shows up 1 times
trap music shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: ['crunk', 'dirty south rap', 'southern hip hop']
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop']
Current artist has: []
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop']
Current artist has: []
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop']
Current artist has: []
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop']
Current artist has: []
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop']
Current artist has: []
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop']
Current artist has: ['chicano rap', 'latin hip hop']
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop']
Current artist has: []
dirty south rap shows up 2 times
pop rap shows up 1 times
southern hip hop shows up 2 times
trap music shows up 1 times
crunk shows up 1 times
dirty south rap shows up 2 times
southern hip hop shows up 2 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop']
Current artist has: ['crunk', 'dirty south rap', 'southern hip hop', 'trap music']
dirty south rap shows up 3 times
pop rap shows up 1 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music']
Current artist has: ['hip pop', 'pop rap']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 1 times
pop rap shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 1 times
pop rap shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap']
Current artist has: ['juggalo']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 1 times
pop rap shows up 2 times
juggalo shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 1 times
pop rap shows up 2 times
juggalo shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 1 times
pop rap shows up 2 times
juggalo shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo']
Current artist has: ['hip pop']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 2 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 2 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 2 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop']
Current artist has: ['hip pop']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 1 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop']
Current artist has: ['chicano rap']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap']
Current artist has: ['jerk']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk']
Current artist has: ['deep trap']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 2 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 2 times
jerk shows up 1 times
deep trap shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: ['chicano rap']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: ['freestyle']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: ['soca']
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
soca shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
soca shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
soca shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: []
dirty south rap shows up 3 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 2 times
dirty south rap shows up 3 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
soca shows up 1 times
All genres we've heard of: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'hip pop', 'pop rap', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: ['crunk', 'dirty south rap']
dirty south rap shows up 4 times
pop rap shows up 2 times
southern hip hop shows up 3 times
trap music shows up 2 times
crunk shows up 3 times
dirty south rap shows up 4 times
southern hip hop shows up 3 times
chicano rap shows up 3 times
latin hip hop shows up 1 times
crunk shows up 3 times
dirty south rap shows up 4 times
southern hip hop shows up 3 times
trap music shows up 2 times
hip pop shows up 3 times
pop rap shows up 2 times
juggalo shows up 1 times
hip pop shows up 3 times
hip pop shows up 3 times
chicano rap shows up 3 times
jerk shows up 1 times
deep trap shows up 1 times
chicano rap shows up 3 times
freestyle shows up 1 times
soca shows up 1 times
crunk shows up 3 times
dirty south rap shows up 4 times
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-17-16ed8a383fbd> in <module>()
     20 
     21 #To remove duplicates. You need to turn a list into a set.
---> 22 unique_genres = set(list_with_duplicates)
     23 for genre in unique_genres:
     24     genre_count = all_genres.count(genre)

NameError: name 'list_with_duplicates' is not defined

In [11]:
#There is a library that comes with Python called Collections
#Inside of it is a magic thing called Counter.

import collections # will import the whole collections
#you can also type
from collections import Counter
#all_genres is a list of strings of genrs with duplicates
#counter will count all te genres for us
counts = collections.Counter(all_genres)
counts.most_common(4) #will give you the four most common genres


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-11-bd2048aff2ff> in <module>()
      7 #all_genres is a list of strings of genrs with duplicates
      8 #counter will count all te genres for us
----> 9 counts = collections.Counter(all_genres)
     10 counts.most_common(4) #will give you the four most common genres

NameError: name 'all_genres' is not defined

In [ ]:
#HOW TO AUTOMATE GETTING ALL THE RESULTS

response = requests.get("https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=10")
small_data = response.json()

In [ ]:
small_data['artists']
print(len(small_data['artists']['items'])) #We only get 10 artists
print(data['artists']['total'])

import math
page_count = math.ceil(4502/50)
#math.ceil rounds up
#math.ceil(page_count)
page_count

In [ ]:
#First page artists 1-50: 
#https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=50
#Second page artists 51-100: 
#https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=50&offset=50
#Third page artists 101-150: 
#https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=50&offset=100
#Fourth page artists 151-200: 
#https://api.spotify.com/v1/search?query=lil&type=artist&market=US&limit=50&offset=150

for page in [0, 1, 2, 3, 4]:
    offset = (page) * 50 #because page 2 is 50 and 2-1 = 1 x 50 = 50
    print("We are on page", page, "with an offset of", offset)

In [ ]:
for page in range(91):
    #Get a page
    offset = page * 50
    print("We are on page", page, "with an offset of", offset)
    
    #Make the request with a changed offset ?offset [offset]
    #data = response.json()
    #add all our new artists to our list of existing artists
    #all_artists = all_artists + data['artists]['items]
    
print("Successfully retrieved", len(all_artists), "artists")

3) Use a for loop to determine who BESIDES Lil Wayne has the highest popularity rating.

Is it the same artist who has the largest number of followers?


In [ ]:
for popularity in lil_names:
    print(popularity['name'], popularity['popularity'], popularity['followers'])
print("Lil Yachty, Lil Uzi Vert, Lil Jon have the highest popularity ratings besides Lil Wayne, and they do not have the largest number of followers.")

ANSWER:

#jonathansoma.com/site/lede/foundations/python-patterns/looping-problems/

second_most_popular_name = "" second_most_popular_score = 0 for artist in artists: print("Looking at", artist['name]', "who has a popularity score of", artist['popularity'])

#THE CONDITIONAL aka what you are testing
print("Comparing", artist['popularity'], "to", most_popular_score)
if artist['popularity'] > most_popular_score and artist['name'] != 'Lil Wayne':

                           OR
if artist['popularity'] > most_popular_score:
    if artist['name'] == "Lil Wayne":
        print("Nice try, Lil Wayne, we don't care")
    else:
        print("Not Lil Wayne, updating our notebook")

    #The change, aka what you are keeping track of
    most_popular_name = artist['name']
    most_popular_score = artist['popularity']

print(most_popular_name, most_popular_score)

But what if more than one person has the highest score?

Aggregation Problem. When you're looping through a series of objects and sometimes you

want to add one of those objects to a different list.

target score = 72

initial condition

second_best_artist = []

for artist in artists: print("Looking at", artist['name'], "who has a popularity of", )

#2: Conditional. When we want to add someone to our list
                           if artist['popularity'] == 72:
                           print("!!! The artist's popularity is 72")
                           #The Change
                           #Add that artist to our list
                           #.append(newthing) is how we do that in Python
                           second_best_artists.append(artist['name'])

print("Our second best artists are:")
                           for artist in second_best_artist:
                           print(artist)

Print a list of Lil's that are more popular than Lil' Kim.


In [ ]:
for kim in lil_names:
    print(kim['name'], kim['id'])

In [ ]:
response = requests.get("https://api.spotify.com/v1/artists/5tth2a3v0sWwV1C7bApBdX/")
kim_data = response.json()

In [ ]:
#print(kim_data)
kim_followers = kim_data['followers']
total_kim_followers = kim_followers['total']
#print(total_kim_followers)

for artists in lil_names:
    if artists["followers"]["total"] > total_kim_followers:
        print(artists['name'], artists['popularity'])

In [ ]:
ANSWER:
    
for artist in artists:
    #print("Looking at", artist['name'])
    if artist['name'] == "Lil' Kim":
        print("Found Lil Kim")
        print(artist['popularity'])
    else:
        pass
        #print("Not Lil Kim")

lil_kim_popularity = 62

for artist in artists:
    if artist['popularity'] > lil_kim_popularity:
        print(artist['name'], "is more popular with a score of", artist['popularity'])
        more_popular_than_lil_kim.append(artist['name'])
    else:
        print(artist['name'], "is less popular with a score of", artist['popularity'])
print("#### More popular than Lil Kim ####"):
    print(artist_name)
    
    more_popular_string = ", ".join(more_popular_than_lil_kim)
    print("Artists mroe popular than Lil Kim are:", more_popular_string)

5) Pick two of your favorite Lils to fight it out, and use their IDs to print out their top tracks.


In [ ]:
#Let's pick Lil Wayne and Lil Mama because I don't know who most of these people are
wayne_id = "55Aa2cqylxrFIXC767Z865"

response = requests.get("https://api.spotify.com/v1/artists/" + wayne_id + "/top-tracks?country=US")
wayne_data = response.json()
top_wayne_tracks = wayne_data['tracks']
for track in top_wayne_tracks:
    print(track["name"])

In [ ]:
mama_id = "5qK5bOC6wLtuLhG5KvU17c"
response = requests.get("https://api.spotify.com/v1/artists/" + mama_id + "/top-tracks?country=US")
mama_data = response.json()

top_mama_tracks = mama_data['tracks']
for track in top_mama_tracks:
    print(track["name"])

Will the world explode if a musician swears? Get an average popularity for their explicit songs vs. their non-explicit songs. How many minutes of explicit songs do they have? Non-explicit?


In [ ]:
wayne_explicit_count = 0
wayne_exp_popularity_count = 0
wayne_ok_count = 0
wayne_ok_popularity_count = 0
wayne_explicit_len = 0
wayne_ok_len = 0
for track in top_wayne_tracks:
    print(track['name'], track['explicit'], track['popularity'], track["duration_ms"])
    if True:
        wayne_explicit_count = wayne_explicit_count + 1
        wayne_exp_popularity_count = wayne_exp_popularity_count + int(track['popularity'])
        wayne_avg_pop = wayne_exp_popularity_count / wayne_explicit_count
        wayne_explicit_len = wayne_explicit_len + int(track["duration_ms"])
    if not track['explicit']:
        wayne_ok_count = wayne_ok_count + 1
        wayne_ok_popularity_count = wayne_ok_popularity_count + track['popularity']
        wayne_ok_avg_pop = wayne_ok_popularity_count / wayne_ok_count
        wayne_ok_len = wayne_ok_len + track["duration_ms"]

if wayne_explicit_count > 0:
    print("The average popularity for Lil Wayne's explicit songs is", wayne_avg_pop)
    #1 minute is 60000 milliseconds, who knew?
    wayne_explicit_mins = int(wayne_explicit_len) / 60000
    print("Lil Wayne has", wayne_explicit_mins, "minutes of explicit songs")
if wayne_ok_count > 0:
    print("The average popularity for Lil Wayne's non-explicit songs is", wayne_ok_avg_pop)
    wayne_ok_mins = int(wayne_ok_len) / 60000
    print("Lil Wayne has", wayne_ok_mins, "minutes of explicit songs")

QUESTION: Why does this return both true and not true statements for non-explicit statements?

for track in top_mama_tracks: print(track['name'], track['explicit']) if True: print(track['name'], "is explicit and has a popularity of", track['popularity']) if not track['explicit']: print(track['name'], "is not explicit and has a popularity of", track['popularity'])


In [ ]:
mama_exp_count = 0
mama_exp_pop_count = 0
mama_ok_count = 0
mama_ok_pop_count = 0
mama_exp_len = 0
mama_ok_len = 0

for track in top_mama_tracks:
    print(track['name'], track['explicit'], track['popularity'], track["duration_ms"])
    if True:
        mama_exp_count = mama_exp_count + 1
        mama_exp_pop_count = mama_exp_pop_count + int(track['popularity'])
        mama_avg_pop = int(mama_exp_pop_count) / int(mama_exp_count)
        mama_exp_len = mama_exp_len + int(track["duration_ms"])
    if not track['explicit']:
        mama_ok_count = mama_ok_count + 1
        mama_ok_pop_count = mama_ok_pop_count + int(track['popularity'])
        mama_ok_avg_pop = int(mama_ok_pop_count) / int(mama_ok_count)
        mama_ok_len = mama_ok_len + int(track["duration_ms"])

if mama_exp_count > 0:
       #1 minute is 60000 milliseconds, who knew?
    print("The average popularity for Lil Mama's xplicit songs is", mama_avg_pop)
    mama_exp_mins = int(mama_exp_len) / 60000
    print("Lil Mama has", mama_exp_mins, "minutes of explicit songs")
if mama_ok_count > 0:
    print("The average popularity for Lil Mama's non-explicit songs is", mama_ok_avg_pop)
    mama_ok_mins = int(mama_ok_len) / 60000
    print("Lil Mama has", mama_ok_mins, "minutes of non-explicit songs")

7) Since we're talking about Lils, what about Biggies? How many total "Biggie" artists are there? How many total "Lil"s? If you made 1 request every 5 seconds, how long would it take to download information on all the Lils vs the Biggies?


In [ ]:
#We need to bypass the limit. And find out

In [ ]:
response = requests.get('https://api.spotify.com/v1/search?query=biggie&type=artist')

In [ ]:
biggie_data = response.json()

In [ ]:
biggie_artists = biggie_data['artists']
biggie_names = biggie_artists['items']
biggie_count= 0

for name in biggie_names:
    print(name['name'])
    biggie_count = biggie_count + 1
print("There are a total number of", biggie_count, "biggie artists")

In [ ]:
response = requests.get('https://api.spotify.com/v1/search?query=lil&type=artist')

In [ ]:
lil_data = response.json()

In [ ]:
lil_x_artists = lil_data['artists']
lil_x_names = lil_x_artists['items']
lil_x_count= 0

for name in lil_x_names:
    print(name['name'])
    lil_x_count = biggie_count + 1
print("There are a total number of", lil_x_count, "lil artists")

8) Out of the top 50 "Lil"s and the top 50 "Biggie"s, who is more popular on average?


In [ ]:
response = requests.get('https://api.spotify.com/v1/search?query=biggie&type=artist&limit=50')

In [ ]:
b_data = response.json()

In [ ]:
b_artists = b_data['artists']
b_names = b_artists['items']
b_pop_count = 0
b_number = 0

for names in b_names:
    print(names['name'], names['popularity'])
    b_number = b_number + 1
    b_pop_count = b_pop_count + int(names['popularity'])
    avg_b_pop = b_pop_count / int(b_number)
print("The Biggies' average popularity is", avg_b_pop)

In [ ]:
lil_pop_count = 0
lil_number = 0

for names in lil_names:
    print(names['name'], names['popularity'])
    lil_number = lil_number + 1
    lil_pop_count = lil_pop_count + int(names['popularity'])
    avg_lil_pop = lil_pop_count / int(lil_number)
print("The Lils average popularity is", avg_lil_pop)

In [ ]:
print("The Lils are far more popular")

In [ ]: