In [13]:
#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.

Graded = 7/8


In [14]:
import requests

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

& for multiple parameters


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

In [17]:
data.keys()


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

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

In [19]:
artist_data.keys()


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

In [20]:
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 [21]:
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 [22]:
#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-22-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 [ ]:
#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

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 [23]:
#TA-Stephan:can't just print the names yourself. The code must do it.
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.")


Lil Wayne 86 {'total': 2634294, 'href': None}
Lil Yachty 74 {'total': 43809, 'href': None}
Lil Uzi Vert 74 {'total': 66068, 'href': None}
Lil Dicky 69 {'total': 233995, 'href': None}
Boosie Badazz 67 {'total': 222113, 'href': None}
Lil Jon 72 {'total': 257173, 'href': None}
King Lil G 61 {'total': 65473, 'href': None}
Lil Durk 60 {'total': 135519, 'href': None}
Lil Jon & The East Side Boyz 60 {'total': 17248, 'href': None}
Lil Bibby 54 {'total': 44845, 'href': None}
G Herbo 53 {'total': 52618, 'href': None}
Lil Rob 50 {'total': 36219, 'href': None}
Lil Reese 50 {'total': 24047, 'href': None}
Lil Scrappy 50 {'total': 27287, 'href': None}
Bow Wow 57 {'total': 119173, 'href': None}
Lil Keke 48 {'total': 18943, 'href': None}
Lil Wyte 50 {'total': 31356, 'href': None}
Lil Blood 46 {'total': 5598, 'href': None}
Lil Snupe 45 {'total': 34376, 'href': None}
Lil Mama 45 {'total': 21261, 'href': None}
Lil Boom 46 {'total': 317, 'href': None}
Lil B 44 {'total': 260, 'href': None}
Lil' Kim 62 {'total': 70832, 'href': None}
Lil Cuete 40 {'total': 15692, 'href': None}
Lil Phat 40 {'total': 5387, 'href': None}
Lil Debbie 43 {'total': 14647, 'href': None}
Lil Twist 40 {'total': 14856, 'href': None}
Lil Trill 37 {'total': 2144, 'href': None}
Lil Goofy 36 {'total': 1358, 'href': None}
Lil Lonnie 37 {'total': 1439, 'href': None}
Lil AJ 37 {'total': 915, 'href': None}
Lil Haiti 38 {'total': 755, 'href': None}
Lil Cray 36 {'total': 1030, 'href': None}
Lil Twon 36 {'total': 335, 'href': None}
Mr. Lil One 36 {'total': 4773, 'href': None}
Lil Mouse 35 {'total': 16406, 'href': None}
Lil Silva 43 {'total': 9570, 'href': None}
Lil Yase 34 {'total': 1182, 'href': None}
Lil Flash 38 {'total': 1797, 'href': None}
Lil Suzy 34 {'total': 5954, 'href': None}
Lil Eddie 41 {'total': 1642, 'href': None}
Lil Rue 34 {'total': 3308, 'href': None}
Lil Kesh 39 {'total': 1700, 'href': None}
Lil Wayne, DJ Drama 35 {'total': 12927, 'href': None}
Lil C 33 {'total': 1714, 'href': None}
Lil Rick 39 {'total': 1841, 'href': None}
Lil E 35 {'total': 143, 'href': None}
Lil June 32 {'total': 1442, 'href': None}
Lil Fate 34 {'total': 113, 'href': None}
Lil' Flip 50 {'total': 20115, 'href': None}
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 [24]:
for kim in lil_names:
    print(kim['name'], kim['id'])


Lil Wayne 55Aa2cqylxrFIXC767Z865
Lil Yachty 6icQOAFXDZKsumw3YXyusw
Lil Uzi Vert 4O15NlyKLIASxsJ0PrXPfz
Lil Dicky 1tqhsYv8yBBdwANFNzHtcr
Boosie Badazz 6z7xFFHxYkE9t8bwIF0Bvg
Lil Jon 7sfl4Xt5KmfyDs2T3SVSMK
King Lil G 6L3x3if9RVimruryD9LoFb
Lil Durk 3hcs9uc56yIGFCSy9leWe7
Lil Jon & The East Side Boyz 3ciRvbBIVz9fBoPbtSYq4x
Lil Bibby 4uSN8Y3kgFNVULUWsZEAVW
G Herbo 5QdEbQJ3ylBnc3gsIASAT5
Lil Rob 7B7TGqQe7QTVm2U6q8jzk1
Lil Reese 1bPxKZtCdjB1aj1csBJpdS
Lil Scrappy 5einkgXXrjhfYCyac1FANB
Bow Wow 7352aRY2mqSxBZwzUb6LmA
Lil Keke 1grI9x4Uzos1Asx8JmRW6T
Lil Wyte 21O7WwRkik43ErKppxDKJq
Lil Blood 74nSA5FdDOuuLw7Rn5JnuP
Lil Snupe 42FaEHFfyxTdZQ5W28dXnj
Lil Mama 5qK5bOC6wLtuLhG5KvU17c
Lil Boom 1mmlWsyPJvvxMdabcGJjRn
Lil B 4dqh62yIzDBmrMeBOLiP5F
Lil' Kim 5tth2a3v0sWwV1C7bApBdX
Lil Cuete 1I5u5Umau1AgHl0ZbPL1oR
Lil Phat 3QnIBUOS4mUzs67rZ8r4c9
Lil Debbie 3FNZcjyqT7F5upP99JV0oN
Lil Twist 564gvOqSRcQoYAhaBpTiK2
Lil Trill 5EQERGi7ffHvHsv3bnqzBn
Lil Goofy 3rWaFjgOi5mjQfllMfN3VI
Lil Lonnie 6zSBkdKFLKKggDtE3amfCk
Lil AJ 2jXwYLNnCxNavms4mc1DYM
Lil Haiti 4E9dumwOMLlTyXUp1i2WdI
Lil Cray 43BqexhEx5NKF7VfeOYP9m
Lil Twon 5YZZbPdI7P7te3lW3dTpzK
Mr. Lil One 6tslWi0BXiDdtChermDzkU
Lil Mouse 1cEHxCgGlEgqBc91YOcAEQ
Lil Silva 2Kv0ApBohrL213X9avMrEn
Lil Yase 4vIlHBnzWKbmWe8ZOkT1ZT
Lil Flash 069qBEK34YGoX7nSIT74Eg
Lil Suzy 5HPsVk1MblCoa44WLJsQwN
Lil Eddie 5CY0QKsbUBpQJIE2yycsYi
Lil Rue 4IFVaKBbEO8Qkurg6nmoc4
Lil Kesh 38XiDu0kK3Z5jdHUDqBzNT
Lil Wayne, DJ Drama 65npPa1U4cgobX9wU7Jgpb
Lil C 69swdLSkKxCQBMYJ55O2mA
Lil Rick 1qKzKUnuQsjB83hBZffoq0
Lil E 0zn6yzsbWj3EPMgOTqfG5k
Lil June 3GH3KD2078kLPpEkN1UN26
Lil Fate 6JUnsP7jmvYmdhbg7lTMQj
Lil' Flip 4Q5sPmM8j4SpMqL4UA1DtS

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

In [27]:
#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'])


Lil Wayne 86
Lil Dicky 69
Boosie Badazz 67
Lil Jon 72
Lil Durk 60
Bow Wow 57

In [29]:
#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)


  File "<ipython-input-29-f2840c9dc655>", line 20
    print("#### More popular than Lil Kim ####"):
                                                ^
SyntaxError: invalid syntax

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


In [30]:
#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"])


Forever
Nothing But Trouble - Instagram Models
6 Foot 7 Foot
A Milli
Right Above It
Lollipop
Rich As Fuck
Love Me
Mirror
Believe Me

In [31]:
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"])


Lip Gloss
Shawty Get Loose
G-Slide (Tour Bus) - Radio Version
Dough Boy
Lip Gloss/ No Music - Main Version - clean
Shawty Get Loose
Hustler Girl
Bad As Me
Truly In Love
L.I.F.E.

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 [32]:
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")


Forever True 75 357346
Nothing But Trouble - Instagram Models True 72 217984
6 Foot 7 Foot True 72 248586
A Milli True 71 221840
Right Above It True 69 271946
Lollipop True 67 299333
Rich As Fuck True 66 223173
Love Me True 66 253440
Mirror True 65 228093
Believe Me True 65 337640
The average popularity for Lil Wayne's explicit songs is 68.8
Lil Wayne has 44.32301666666667 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 [33]:
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")


Lip Gloss False 59 219773
Shawty Get Loose False 33 209506
G-Slide (Tour Bus) - Radio Version False 35 211973
Dough Boy False 30 210050
Lip Gloss/ No Music - Main Version - clean False 29 244133
Shawty Get Loose False 25 188333
Hustler Girl True 23 338311
Bad As Me True 21 187742
Truly In Love False 19 247893
L.I.F.E. False 18 237640
The average popularity for Lil Mama's xplicit songs is 29.2
Lil Mama has 38.2559 minutes of explicit songs
The average popularity for Lil Mama's non-explicit songs is 31.0
Lil Mama has 29.48835 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 [34]:
response = requests.get('https://api.spotify.com/v1/search?query=biggie&type=artist')

In [35]:
biggie_data = response.json()

In [36]:
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")


The Notorious B.I.G.
Biggie D
Biggie
Biggie Irie
Fabolous|Biggie|Busta|Nate Dogg
Biggie Smalls
Biggie Paul
Biggie the Kid
Alief Biggie
Papa Biggie
Mister Biggie
Biggie & Foldy
Biggie Bash
Dj Majah & Blaq Biggie Blaq
Biggie Tembo
Louis Biggie
Biggie Da Roxter
Biggie Dutch
Biggie Dutch feat. Marina Wilde
MC Biggie
There are a total number of 20 biggie artists

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

In [38]:
lil_data = response.json()

In [39]:
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")


Lil Wayne
Lil Yachty
Lil Uzi Vert
Lil Dicky
Boosie Badazz
Lil Jon
King Lil G
Lil Durk
Lil Jon & The East Side Boyz
Lil Bibby
G Herbo
Lil Rob
Lil Reese
Lil Scrappy
Bow Wow
Lil Keke
Lil Wyte
Lil Blood
Lil Snupe
Lil Mama
There are a total number of 21 lil artists

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


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

In [41]:
b_data = response.json()

In [42]:
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)


The Notorious B.I.G. 76
Biggie D 20
Biggie 23
Biggie Irie 16
Fabolous|Biggie|Busta|Nate Dogg 11
Biggie Smalls 13
Biggie Paul 17
Biggie the Kid 4
Alief Biggie 4
Papa Biggie 0
Mister Biggie 0
Biggie & Foldy 0
Biggie Bash 6
Dj Majah & Blaq Biggie Blaq 2
Biggie Tembo 0
Louis Biggie 0
Biggie Da Roxter 0
Biggie Dutch 0
Biggie Dutch feat. Marina Wilde 0
MC Biggie 0
Mr Biggie 0
Biggie & Anjay 0
Balder & Biggie 2
Poppa Biggie 0
Biggie Mic 0
Babie Biggie 0
Biggie Moe 0
MC Biggiedoy 0
Biggie Lu 0
Biggie Bandit 0
Biggie Babylon 0
Biggieballzh 0
1000 LBS (Biggie Irie 0
Biggie Brown 0
Biggie Vinkeloe 0
Biggie Sam 0
Crenshaw Biggie 0
Biggie Whit 0
Biggie Smiles 0
Biggie Nabwelela 1
Biggie Roggie Shirima 0
Wandung'u Biggie 0
Biggie Jackson 0
Kevy K Biggie 0
Andrew Biggie 0
Biggie Fab 0
Dj Biggie B 0
Biggie Talls 0
Biggie Smalls Featuring Grand Puba 0
Luke Biggie 0
The Biggies' average popularity is 3.9

In [43]:
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)


Lil Wayne 86
Lil Yachty 74
Lil Uzi Vert 74
Lil Dicky 69
Boosie Badazz 67
Lil Jon 72
King Lil G 61
Lil Durk 60
Lil Jon & The East Side Boyz 60
Lil Bibby 54
G Herbo 53
Lil Rob 50
Lil Reese 50
Lil Scrappy 50
Bow Wow 57
Lil Keke 48
Lil Wyte 50
Lil Blood 46
Lil Snupe 45
Lil Mama 45
Lil Boom 46
Lil B 44
Lil' Kim 62
Lil Cuete 40
Lil Phat 40
Lil Debbie 43
Lil Twist 40
Lil Trill 37
Lil Goofy 36
Lil Lonnie 37
Lil AJ 37
Lil Haiti 38
Lil Cray 36
Lil Twon 36
Mr. Lil One 36
Lil Mouse 35
Lil Silva 43
Lil Yase 34
Lil Flash 38
Lil Suzy 34
Lil Eddie 41
Lil Rue 34
Lil Kesh 39
Lil Wayne, DJ Drama 35
Lil C 33
Lil Rick 39
Lil E 35
Lil June 32
Lil Fate 34
Lil' Flip 50
The Lils average popularity is 46.7

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


The Lils are far more popular

In [ ]: