In [1]:
import requests

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 [15]:
response = requests.get("https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&market=US")
data = response.json()

In [16]:
type(data)


Out[16]:
dict

In [17]:
data.keys()


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

In [18]:
type(data['artists'])


Out[18]:
dict

In [19]:
data['artists'].keys()


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

In [20]:
artists = data['artists']['items']
#artists

In [22]:
for artist in artists:
    print(artist['name'], artist['popularity'])


Lil Wayne 86
Lil Yachty 72
Lil Uzi Vert 72
Lil Dicky 68
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 Keke 48
Bow Wow 57
Lil Scrappy 48
Lil Wyte 50
Lil Blood 45
Lil Snupe 45
Lil Mama 45
Lil B 44
Lil' Kim 62
Lil Cuete 40
Lil Phat 39
Lil Debbie 43
Lil Twist 39
Lil Trill 37
Lil Twon 38
Lil AJ 37
Lil Lonnie 37
Lil Boom 35
Lil Goofy 35
Mr. Lil One 36
Lil Haiti 36
Lil Flash 38
Lil Kesh 39
Lil Cray 35
Lil Silva 43
Lil Rue 34
Lil Eddie 41
Lil Yase 33
Lil Wayne, DJ Drama 35
Lil Suzy 34
Lil Mouse 34
Lil C 33
Lil Rick 39
Lil June 32
Lil E 34
Lil Fate 34
Lil' Flip 49

In [ ]:

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 [32]:
for artist in artists:
    print(artist['name'], artist['popularity'])
    # YES dirty south rap, pop rap, southern hip hop, trap music
    # NO ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
    if len(artist['genres']) == 0:
        print("No genres listed")
    else:
        genres = ", ".join(artist['genres'])
        print("Genre list: ", genres)


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

In [ ]:


In [ ]:


In [ ]:


In [ ]:

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 [44]:
most_popular_name = ""
most_popular_score = 0
for artist in artists:
    print("Looking at", artist['name'], "who has a popularity score of", artist['popularity'])
    # THE CONDITIONAL
    # a.k.a. what you are testing
    print("Comparing", artist['popularity'], "to", most_popular_score)
    # Seeing if the artist is more popular that what we've saved
    if artist['popularity'] > most_popular_score:
        print("FOUND A NEW MOST POPULAR, checking to see if it's Lil Wayne trying to sneak through")
        # Seeing if it's actually Lil Wayne
        if artist['name'] == "Lil Wayne":
            print("Nice try Lil Wayne, we don't care")
        else:
            # THE CHANGE
            # a.k.a. what you're keeping track of
            print("Not Lil Wayne, updating our notebook")
            most_popular_name = artist['name']
            most_popular_score = artist['popularity']
print("#########")
print(most_popular_name, most_popular_score)


Looking at Lil Wayne who has a popularity score of 86
Comparing 86 to 0
FOUND A NEW MOST POPULAR, checking to see if it's Lil Wayne trying to sneak through
Nice try Lil Wayne, we don't care
Looking at Lil Yachty who has a popularity score of 72
Comparing 72 to 0
FOUND A NEW MOST POPULAR, checking to see if it's Lil Wayne trying to sneak through
Not Lil Wayne, updating our notebook
Looking at Lil Uzi Vert who has a popularity score of 72
Comparing 72 to 72
Looking at Lil Dicky who has a popularity score of 68
Comparing 68 to 72
Looking at Boosie Badazz who has a popularity score of 67
Comparing 67 to 72
Looking at Lil Jon who has a popularity score of 72
Comparing 72 to 72
Looking at King Lil G who has a popularity score of 61
Comparing 61 to 72
Looking at Lil Durk who has a popularity score of 60
Comparing 60 to 72
Looking at Lil Jon & The East Side Boyz who has a popularity score of 60
Comparing 60 to 72
Looking at Lil Bibby who has a popularity score of 54
Comparing 54 to 72
Looking at G Herbo who has a popularity score of 53
Comparing 53 to 72
Looking at Lil Rob who has a popularity score of 50
Comparing 50 to 72
Looking at Lil Reese who has a popularity score of 50
Comparing 50 to 72
Looking at Lil Keke who has a popularity score of 48
Comparing 48 to 72
Looking at Bow Wow who has a popularity score of 57
Comparing 57 to 72
Looking at Lil Scrappy who has a popularity score of 48
Comparing 48 to 72
Looking at Lil Wyte who has a popularity score of 50
Comparing 50 to 72
Looking at Lil Blood who has a popularity score of 45
Comparing 45 to 72
Looking at Lil Snupe who has a popularity score of 45
Comparing 45 to 72
Looking at Lil Mama who has a popularity score of 45
Comparing 45 to 72
Looking at Lil B who has a popularity score of 44
Comparing 44 to 72
Looking at Lil' Kim who has a popularity score of 62
Comparing 62 to 72
Looking at Lil Cuete who has a popularity score of 40
Comparing 40 to 72
Looking at Lil Phat who has a popularity score of 39
Comparing 39 to 72
Looking at Lil Debbie who has a popularity score of 43
Comparing 43 to 72
Looking at Lil Twist who has a popularity score of 39
Comparing 39 to 72
Looking at Lil Trill who has a popularity score of 37
Comparing 37 to 72
Looking at Lil Twon who has a popularity score of 38
Comparing 38 to 72
Looking at Lil AJ who has a popularity score of 37
Comparing 37 to 72
Looking at Lil Lonnie who has a popularity score of 37
Comparing 37 to 72
Looking at Lil Boom who has a popularity score of 35
Comparing 35 to 72
Looking at Lil Goofy who has a popularity score of 35
Comparing 35 to 72
Looking at Mr. Lil One who has a popularity score of 36
Comparing 36 to 72
Looking at Lil Haiti who has a popularity score of 36
Comparing 36 to 72
Looking at Lil Flash who has a popularity score of 38
Comparing 38 to 72
Looking at Lil Kesh who has a popularity score of 39
Comparing 39 to 72
Looking at Lil Cray who has a popularity score of 35
Comparing 35 to 72
Looking at Lil Silva who has a popularity score of 43
Comparing 43 to 72
Looking at Lil Rue who has a popularity score of 34
Comparing 34 to 72
Looking at Lil Eddie who has a popularity score of 41
Comparing 41 to 72
Looking at Lil Yase who has a popularity score of 33
Comparing 33 to 72
Looking at Lil Wayne, DJ Drama who has a popularity score of 35
Comparing 35 to 72
Looking at Lil Suzy who has a popularity score of 34
Comparing 34 to 72
Looking at Lil Mouse who has a popularity score of 34
Comparing 34 to 72
Looking at Lil C who has a popularity score of 33
Comparing 33 to 72
Looking at Lil Rick who has a popularity score of 39
Comparing 39 to 72
Looking at Lil June who has a popularity score of 32
Comparing 32 to 72
Looking at Lil E who has a popularity score of 34
Comparing 34 to 72
Looking at Lil Fate who has a popularity score of 34
Comparing 34 to 72
Looking at Lil' Flip who has a popularity score of 49
Comparing 49 to 72
#########
Lil Yachty 72

In [53]:
name = "Lil Soma"

target_score = 72
# 1: INITIAL CONDITION
# We have no one who is in our list yet
second_best_artists = []

# AGGREGATION PROBLEM
# When you're looping through a series of serious objects
# and sometimes you want to add one of those objects
# to a DIFFERENT list
for artist in artists:
    # Let's print out what's on our notebook
    print("Notebook is", second_best_artists)
    print("Looking at", artist['name'], "who has a popularity of", artist['popularity'])
    # 2: CONDITIONAL
    # when we want to add someone to our list
    if artist['popularity'] == 72:
        print("!!!!!!!! The artist's popularity is 72")
        # 3: 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_artists:
    print(artist)


Notebook is ['Lil Yachty']
Looking at Lil Wayne who has a popularity of 86
Notebook is ['Lil Yachty']
Looking at Lil Yachty who has a popularity of 72
!!!!!!!! The artist's popularity is 72
Notebook is ['Lil Yachty', 'Lil Yachty']
Looking at Lil Uzi Vert who has a popularity of 72
!!!!!!!! The artist's popularity is 72
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert']
Looking at Lil Dicky who has a popularity of 68
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert']
Looking at Boosie Badazz who has a popularity of 67
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert']
Looking at Lil Jon who has a popularity of 72
!!!!!!!! The artist's popularity is 72
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at King Lil G who has a popularity of 61
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Durk who has a popularity of 60
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Jon & The East Side Boyz who has a popularity of 60
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Bibby who has a popularity of 54
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at G Herbo who has a popularity of 53
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Rob who has a popularity of 50
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Reese who has a popularity of 50
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Keke who has a popularity of 48
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Bow Wow who has a popularity of 57
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Scrappy who has a popularity of 48
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Wyte who has a popularity of 50
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Blood who has a popularity of 45
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Snupe who has a popularity of 45
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Mama who has a popularity of 45
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil B who has a popularity of 44
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil' Kim who has a popularity of 62
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Cuete who has a popularity of 40
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Phat who has a popularity of 39
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Debbie who has a popularity of 43
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Twist who has a popularity of 39
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Trill who has a popularity of 37
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Twon who has a popularity of 38
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil AJ who has a popularity of 37
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Lonnie who has a popularity of 37
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Boom who has a popularity of 35
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Goofy who has a popularity of 35
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Mr. Lil One who has a popularity of 36
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Haiti who has a popularity of 36
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Flash who has a popularity of 38
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Kesh who has a popularity of 39
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Cray who has a popularity of 35
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Silva who has a popularity of 43
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Rue who has a popularity of 34
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Eddie who has a popularity of 41
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Yase who has a popularity of 33
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Wayne, DJ Drama who has a popularity of 35
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Suzy who has a popularity of 34
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Mouse who has a popularity of 34
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil C who has a popularity of 33
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Rick who has a popularity of 39
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil June who has a popularity of 32
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil E who has a popularity of 34
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil Fate who has a popularity of 34
Notebook is ['Lil Yachty', 'Lil Yachty', 'Lil Uzi Vert', 'Lil Jon']
Looking at Lil' Flip who has a popularity of 49
OUR SECOND BEST ARTISTS ARE:
Lil Yachty
Lil Yachty
Lil Uzi Vert
Lil Jon

In [ ]:


In [ ]:


In [ ]:

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


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


Found Lil Kim
62

In [70]:
lil_kim_popularity = 62

# AGGREGATION PROBLEM
more_popular_than_lil_kim = []

# THE LOOP
for artist in artists:
    # THE CONDITIONAL! is the artist more popular than lil kim?
    if artist['popularity'] > lil_kim_popularity:
        # IF yes, let's add them to our list
        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 #####")
for artist_name in more_popular_than_lil_kim:
    print(artist_name)


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

In [72]:
for artist_name in more_popular_than_lil_kim:
    print(artist_name)

more_popular_string = ", ".join(more_popular_than_lil_kim)
print("Artists more popular than Lil' Kim are:", more_popular_string)


Lil Wayne
Lil Yachty
Lil Uzi Vert
Lil Dicky
Boosie Badazz
Lil Jon
Artists more popular than Lil' Kim are: Lil Wayne, Lil Yachty, Lil Uzi Vert, Lil Dicky, Boosie Badazz, Lil Jon

5) Pick two of your favorite Lils to fight it out, and use their IDs to print out their top tracks. Tip: You're going to be making two separate requests, be sure you DO NOT save them into the same variable.


In [ ]:


In [ ]:


In [ ]:

How to count the genres


In [78]:
# AGGREGATION PROBLEM
all_genres = []

# THE LOOP
for artist in artists:
    print("ALL GENRES WE'VE HEARD OF:", all_genres)
    # THE CONDITIONAL: none
    print("Current artist has:", artist['genres'])
    all_genres = all_genres + artist['genres']

# "Hello" + "world" => "Helloworld"   
# [1, 2, 3] + [4, 5, 6] => [1, 2, 3, 4, 5, 6]
# [1, 2, 3] + 4 => DOES NOT WORK
# [1, 2, 3].append(4) => [1, 2, 3, 4]

print("########")
print("ALL THE GENRES WE'VE HEARD OF, FINALLY, AT THE END:")
# Has repeats
print(all_genres)

# your_list = ['a', 'b', 'c', 'd', 'c', 'b', 'c']
# your_list.count('c') => 3
# your_list.count('a') => 1
# your_list.count('d') => 1


ALL GENRES WE'VE HEARD OF: []
Current artist has: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
ALL GENRES WE'VE HEARD OF: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
ALL GENRES WE'VE HEARD OF: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
ALL GENRES WE'VE HEARD OF: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
ALL GENRES WE'VE HEARD OF: ['dirty south rap', 'pop rap', 'southern hip hop', 'trap music']
Current artist has: []
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']
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: []
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: []
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: []
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: []
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: []
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']
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: []
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: []
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: ['hip pop', 'pop rap']
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', 'hip pop', 'pop rap']
Current artist has: ['crunk', 'dirty south rap', 'southern hip hop', 'trap music']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music']
Current artist has: ['juggalo']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo']
Current artist has: ['hip pop']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop']
Current artist has: ['hip pop']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop']
Current artist has: ['chicano rap']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap']
Current artist has: ['jerk']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk']
Current artist has: ['deep trap']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap']
Current artist has: ['chicano rap']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap']
Current artist has: ['freestyle']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle']
Current artist has: ['soca']
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: []
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', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca']
Current artist has: ['crunk', 'dirty south rap']
########
ALL THE GENRES WE'VE HEARD OF, FINALLY, AT THE END:
['dirty south rap', 'pop rap', 'southern hip hop', 'trap music', 'crunk', 'dirty south rap', 'southern hip hop', 'chicano rap', 'latin hip hop', 'hip pop', 'pop rap', 'crunk', 'dirty south rap', 'southern hip hop', 'trap music', 'juggalo', 'hip pop', 'hip pop', 'chicano rap', 'jerk', 'deep trap', 'chicano rap', 'freestyle', 'soca', 'crunk', 'dirty south rap']

In [79]:
all_genres.count('dirty south rap')


Out[79]:
4

In [80]:
all_genres.count('crunk')


Out[80]:
3

In [82]:
# This is bad because of the duplicates in all_genres
# It keeps repeating "dirty south rap shows up 4 times"
for genre in all_genres:
    genre_count = all_genres.count(genre)
    print(genre, "shows up", genre_count, "times")


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
hip pop shows up 3 times
pop rap shows up 2 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
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

In [84]:
# We need a UNIQUE list of all_genres, a.k.a. a list
# with all duplicates removed
# unique_list = set(list_with_duplicates)
unique_genres = set(all_genres)
for genre in unique_genres:
    genre_count = all_genres.count(genre)
    print(genre, "shows up", genre_count, "times")


pop rap shows up 2 times
deep trap shows up 1 times
dirty south rap shows up 4 times
jerk shows up 1 times
soca shows up 1 times
chicano rap shows up 3 times
southern hip hop shows up 3 times
hip pop shows up 3 times
freestyle shows up 1 times
crunk shows up 3 times
trap music shows up 2 times
latin hip hop shows up 1 times
juggalo shows up 1 times

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

#import collections
from collections import Counter

# all_genres = [ 'southern hip hop', 'southern hip hop', 'crunk', ]
# a list of strings of genres, with duplicates
#counts = collections.Counter(all_genres)
counts = Counter(all_genres)
print('crunk shows up', counts['crunk'], 'times')
print('dirty south rap shows up', counts['dirty south rap'], 'times')
counts.most_common(4)


crunk shows up 3 times
dirty south rap shows up 4 times
Out[101]:
[('dirty south rap', 4),
 ('chicano rap', 3),
 ('southern hip hop', 3),
 ('hip pop', 3)]

In [ ]:

How to automate getting all of the results


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


50
4502

In [124]:
import math

#response = requests.get("https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&market=US")
#data = response.json()
# math.ceil rounds up
page_count = math.ceil(4502 / 50)
page_count


Out[124]:
91

In [128]:
range(91) # gives us a list of 0 through 90
#list(range(91))


Out[128]:
range(0, 91)

In [132]:
# FIRST PAGE: artists 1-50, offset of 0
# https://api.spotify.com/v1/search?q=lil&type=artist&limit=50
# SECOND PAGE: artists 51-100, offset of 50
# https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=50
# THIRD PAGE: artists 101-150, offset of 100
# https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=100
# FOURTH PAGE: artists 151-200, offset of 150
# https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=100
# AGGREGATE
all_artists = []
for page in range(91):
    offset = page * 50
    print("We are on page", page, "with an offset of", offset)
    
    # Make the request with a changed offset ?offset={offset}
    url = "https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=" + str(offset)
    print("Requesting", url)
    response = requests.get(url)
    data = response.json()
    # add our new artists to our list of existing artists
    print("Found", len(data['artists']['items']), "new artists")
    all_artists = all_artists + data['artists']['items']
    print("Total count of artists:", len(all_artists))
    
print("Successfully retrieved", len(all_artists), "artists")


We are on page 0 with an offset of 0
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=0
Found 50 new artists
Total count of artists: 50
We are on page 1 with an offset of 50
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=50
Found 50 new artists
Total count of artists: 100
We are on page 2 with an offset of 100
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=100
Found 50 new artists
Total count of artists: 150
We are on page 3 with an offset of 150
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=150
Found 50 new artists
Total count of artists: 200
We are on page 4 with an offset of 200
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=200
Found 50 new artists
Total count of artists: 250
We are on page 5 with an offset of 250
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=250
Found 50 new artists
Total count of artists: 300
We are on page 6 with an offset of 300
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=300
Found 50 new artists
Total count of artists: 350
We are on page 7 with an offset of 350
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=350
Found 50 new artists
Total count of artists: 400
We are on page 8 with an offset of 400
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=400
Found 50 new artists
Total count of artists: 450
We are on page 9 with an offset of 450
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=450
Found 50 new artists
Total count of artists: 500
We are on page 10 with an offset of 500
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=500
Found 50 new artists
Total count of artists: 550
We are on page 11 with an offset of 550
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=550
Found 50 new artists
Total count of artists: 600
We are on page 12 with an offset of 600
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=600
Found 50 new artists
Total count of artists: 650
We are on page 13 with an offset of 650
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=650
Found 50 new artists
Total count of artists: 700
We are on page 14 with an offset of 700
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=700
Found 50 new artists
Total count of artists: 750
We are on page 15 with an offset of 750
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=750
Found 50 new artists
Total count of artists: 800
We are on page 16 with an offset of 800
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=800
Found 50 new artists
Total count of artists: 850
We are on page 17 with an offset of 850
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=850
Found 50 new artists
Total count of artists: 900
We are on page 18 with an offset of 900
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=900
Found 50 new artists
Total count of artists: 950
We are on page 19 with an offset of 950
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=950
Found 50 new artists
Total count of artists: 1000
We are on page 20 with an offset of 1000
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1000
Found 50 new artists
Total count of artists: 1050
We are on page 21 with an offset of 1050
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1050
Found 50 new artists
Total count of artists: 1100
We are on page 22 with an offset of 1100
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1100
Found 50 new artists
Total count of artists: 1150
We are on page 23 with an offset of 1150
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1150
Found 50 new artists
Total count of artists: 1200
We are on page 24 with an offset of 1200
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1200
Found 50 new artists
Total count of artists: 1250
We are on page 25 with an offset of 1250
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1250
Found 50 new artists
Total count of artists: 1300
We are on page 26 with an offset of 1300
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1300
Found 50 new artists
Total count of artists: 1350
We are on page 27 with an offset of 1350
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1350
Found 50 new artists
Total count of artists: 1400
We are on page 28 with an offset of 1400
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1400
Found 50 new artists
Total count of artists: 1450
We are on page 29 with an offset of 1450
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1450
Found 50 new artists
Total count of artists: 1500
We are on page 30 with an offset of 1500
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1500
Found 50 new artists
Total count of artists: 1550
We are on page 31 with an offset of 1550
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1550
Found 50 new artists
Total count of artists: 1600
We are on page 32 with an offset of 1600
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1600
Found 50 new artists
Total count of artists: 1650
We are on page 33 with an offset of 1650
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1650
Found 50 new artists
Total count of artists: 1700
We are on page 34 with an offset of 1700
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1700
Found 50 new artists
Total count of artists: 1750
We are on page 35 with an offset of 1750
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1750
Found 50 new artists
Total count of artists: 1800
We are on page 36 with an offset of 1800
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1800
Found 50 new artists
Total count of artists: 1850
We are on page 37 with an offset of 1850
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1850
Found 50 new artists
Total count of artists: 1900
We are on page 38 with an offset of 1900
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1900
Found 50 new artists
Total count of artists: 1950
We are on page 39 with an offset of 1950
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=1950
Found 50 new artists
Total count of artists: 2000
We are on page 40 with an offset of 2000
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2000
Found 50 new artists
Total count of artists: 2050
We are on page 41 with an offset of 2050
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2050
Found 50 new artists
Total count of artists: 2100
We are on page 42 with an offset of 2100
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2100
Found 50 new artists
Total count of artists: 2150
We are on page 43 with an offset of 2150
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2150
Found 50 new artists
Total count of artists: 2200
We are on page 44 with an offset of 2200
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2200
Found 50 new artists
Total count of artists: 2250
We are on page 45 with an offset of 2250
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2250
Found 50 new artists
Total count of artists: 2300
We are on page 46 with an offset of 2300
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2300
Found 50 new artists
Total count of artists: 2350
We are on page 47 with an offset of 2350
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2350
Found 50 new artists
Total count of artists: 2400
We are on page 48 with an offset of 2400
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2400
Found 50 new artists
Total count of artists: 2450
We are on page 49 with an offset of 2450
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2450
Found 50 new artists
Total count of artists: 2500
We are on page 50 with an offset of 2500
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2500
Found 50 new artists
Total count of artists: 2550
We are on page 51 with an offset of 2550
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2550
Found 50 new artists
Total count of artists: 2600
We are on page 52 with an offset of 2600
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2600
Found 50 new artists
Total count of artists: 2650
We are on page 53 with an offset of 2650
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2650
Found 50 new artists
Total count of artists: 2700
We are on page 54 with an offset of 2700
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2700
Found 50 new artists
Total count of artists: 2750
We are on page 55 with an offset of 2750
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2750
Found 50 new artists
Total count of artists: 2800
We are on page 56 with an offset of 2800
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2800
Found 50 new artists
Total count of artists: 2850
We are on page 57 with an offset of 2850
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2850
Found 50 new artists
Total count of artists: 2900
We are on page 58 with an offset of 2900
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2900
Found 50 new artists
Total count of artists: 2950
We are on page 59 with an offset of 2950
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=2950
Found 50 new artists
Total count of artists: 3000
We are on page 60 with an offset of 3000
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3000
Found 50 new artists
Total count of artists: 3050
We are on page 61 with an offset of 3050
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3050
Found 50 new artists
Total count of artists: 3100
We are on page 62 with an offset of 3100
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3100
Found 50 new artists
Total count of artists: 3150
We are on page 63 with an offset of 3150
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3150
Found 50 new artists
Total count of artists: 3200
We are on page 64 with an offset of 3200
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3200
Found 50 new artists
Total count of artists: 3250
We are on page 65 with an offset of 3250
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3250
Found 50 new artists
Total count of artists: 3300
We are on page 66 with an offset of 3300
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3300
Found 50 new artists
Total count of artists: 3350
We are on page 67 with an offset of 3350
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3350
Found 50 new artists
Total count of artists: 3400
We are on page 68 with an offset of 3400
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3400
Found 50 new artists
Total count of artists: 3450
We are on page 69 with an offset of 3450
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3450
Found 50 new artists
Total count of artists: 3500
We are on page 70 with an offset of 3500
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3500
Found 50 new artists
Total count of artists: 3550
We are on page 71 with an offset of 3550
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3550
Found 50 new artists
Total count of artists: 3600
We are on page 72 with an offset of 3600
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3600
Found 50 new artists
Total count of artists: 3650
We are on page 73 with an offset of 3650
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3650
Found 50 new artists
Total count of artists: 3700
We are on page 74 with an offset of 3700
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3700
Found 50 new artists
Total count of artists: 3750
We are on page 75 with an offset of 3750
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3750
Found 50 new artists
Total count of artists: 3800
We are on page 76 with an offset of 3800
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3800
Found 50 new artists
Total count of artists: 3850
We are on page 77 with an offset of 3850
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3850
Found 50 new artists
Total count of artists: 3900
We are on page 78 with an offset of 3900
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3900
Found 50 new artists
Total count of artists: 3950
We are on page 79 with an offset of 3950
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=3950
Found 50 new artists
Total count of artists: 4000
We are on page 80 with an offset of 4000
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4000
Found 50 new artists
Total count of artists: 4050
We are on page 81 with an offset of 4050
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4050
Found 50 new artists
Total count of artists: 4100
We are on page 82 with an offset of 4100
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4100
Found 50 new artists
Total count of artists: 4150
We are on page 83 with an offset of 4150
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4150
Found 50 new artists
Total count of artists: 4200
We are on page 84 with an offset of 4200
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4200
Found 50 new artists
Total count of artists: 4250
We are on page 85 with an offset of 4250
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4250
Found 50 new artists
Total count of artists: 4300
We are on page 86 with an offset of 4300
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4300
Found 50 new artists
Total count of artists: 4350
We are on page 87 with an offset of 4350
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4350
Found 50 new artists
Total count of artists: 4400
We are on page 88 with an offset of 4400
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4400
Found 50 new artists
Total count of artists: 4450
We are on page 89 with an offset of 4450
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4450
Found 50 new artists
Total count of artists: 4500
We are on page 90 with an offset of 4500
Requesting https://api.spotify.com/v1/search?q=lil&type=artist&limit=50&offset=4500
Found 2 new artists
Total count of artists: 4502
Successfully retrieved 4502 artists

In [133]:
len(all_artists)


Out[133]:
4502

In [136]:
all_artists[4200]


Out[136]:
{'external_urls': {'spotify': 'https://open.spotify.com/artist/2s1nWxRrM0pPD4QeVeTwwK'},
 'followers': {'href': None, 'total': 1},
 'genres': [],
 'href': 'https://api.spotify.com/v1/artists/2s1nWxRrM0pPD4QeVeTwwK',
 'id': '2s1nWxRrM0pPD4QeVeTwwK',
 'images': [],
 'name': "P.K.O. featuring Lil' Sin",
 'popularity': 0,
 'type': 'artist',
 'uri': 'spotify:artist:2s1nWxRrM0pPD4QeVeTwwK'}

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [137]:
response = requests.get("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson")
data = response.json()

In [138]:
type(data)


Out[138]:
dict

In [139]:
data.keys()


Out[139]:
dict_keys(['type', 'metadata', 'features', 'bbox'])

In [140]:
type(data['features'])


Out[140]:
list

In [142]:
# How many earthquakes in the past day?
len(data['features'])


Out[142]:
171

In [144]:
# Taking a look at the first one
data['features'][0]


Out[144]:
{'geometry': {'coordinates': [-122.8119965, 38.8148346, 1.35],
  'type': 'Point'},
 'id': 'nc72647876',
 'properties': {'alert': None,
  'cdi': None,
  'code': '72647876',
  'detail': 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/nc72647876.geojson',
  'dmin': 0.008679,
  'felt': None,
  'gap': 89,
  'ids': ',nc72647876,',
  'mag': None,
  'magType': None,
  'mmi': None,
  'net': 'nc',
  'nst': 22,
  'place': '6km NW of The Geysers, California',
  'rms': 0.03,
  'sig': 0,
  'sources': ',nc,',
  'status': 'automatic',
  'time': 1465403381010,
  'title': 'M ? - 6km NW of The Geysers, California',
  'tsunami': 0,
  'type': 'earthquake',
  'types': ',general-link,geoserve,nearby-cities,origin,phase-data,',
  'tz': -420,
  'updated': 1465403394371,
  'url': 'http://earthquake.usgs.gov/earthquakes/eventpage/nc72647876'},
 'type': 'Feature'}

In [146]:
data['features'][0].keys()


Out[146]:
dict_keys(['type', 'geometry', 'properties', 'id'])

In [148]:
data['features'][0]['properties'].keys()


Out[148]:
dict_keys(['dmin', 'nst', 'time', 'updated', 'gap', 'place', 'title', 'tsunami', 'sources', 'net', 'rms', 'status', 'code', 'types', 'ids', 'mmi', 'sig', 'cdi', 'alert', 'tz', 'url', 'mag', 'detail', 'magType', 'type', 'felt'])

In [149]:
data['features'][0]['properties']['place']


Out[149]:
'6km NW of The Geysers, California'

In [151]:
for earthquake in data['features']:
    print(earthquake['properties']['place'])


6km NW of The Geysers, California
10km SSW of Alamo, Nevada
6km W of Cobb, California
27km SSE of Medford, Oklahoma
18km ESE of Anza, CA
11km NE of Cabazon, CA
6km WNW of The Geysers, California
117km W of Cantwell, Alaska
78km NE of Cape Yakataga, Alaska
3km WSW of Cobb, California
8km SSW of Ridgemark, California
8km SSW of Ridgemark, California
69km N of Charlotte Amalie, U.S. Virgin Islands
63km ENE of Cape Yakataga, Alaska
51km ENE of Mammoth Lakes, California
3km SSE of The Geysers, California
6km NW of The Geysers, California
15km ESE of Cohoe, Alaska
25km E of Little Lake, CA
Southern Mid-Atlantic Ridge
14km N of Ocotillo, CA
9km WNW of The Geysers, California
17km ESE of Anza, CA
20km ESE of Anza, CA
13km ENE of Willow, Alaska
24km NNE of Cape Yakataga, Alaska
25km SSW of Coalinga, California
50km SSE of Korsakov, Russia
16km W of Ocotillo, CA
9km NNW of Anza, CA
Mid-Indian Ridge
21km SSE of Waimea, Hawaii
9km WNW of Cobb, California
38km S of Puerto San Jose, Guatemala
8km SW of Alamo, Nevada
11km W of Pablo, Montana
56km SW of Tok, Alaska
13km SSW of Talkeetna, Alaska
9km WNW of Cobb, California
78km SW of Puerto El Triunfo, El Salvador
26km N of Cape Yakataga, Alaska
33km SSE of Redoubt Volcano, Alaska
8km WNW of Broadmoor, California
142km SE of McGrath, Alaska
23km SW of Coalinga, California
10km NNE of Borrego Springs, CA
45km E of Cape Yakataga, Alaska
3km NNE of Murrieta Hot Springs, CA
Central East Pacific Rise
8km ENE of Anza, CA
64km ENE of Cantwell, Alaska
6km NW of The Geysers, California
78km NW of Yakutat, Alaska
5km WNW of Cobb, California
44km ENE of Cape Yakataga, Alaska
22km ESE of Hawthorne, Nevada
66km NNE of Sutton-Alpine, Alaska
80km NW of Yakutat, Alaska
68km NNW of Road Town, British Virgin Islands
19km NNW of North Nenana, Alaska
44km W of Big Lake, Alaska
62km N of Charlotte Amalie, U.S. Virgin Islands
4km NE of Colwood, Canada
80km NW of Yakutat, Alaska
35km E of Sutton-Alpine, Alaska
81km NW of Yakutat, Alaska
29km W of Ferndale, California
4km S of Idyllwild, CA
32km NW of Redoubt Volcano, Alaska
14km WNW of Anza, CA
14km WNW of Anza, CA
77km NW of Yakutat, Alaska
1km WNW of Bonney Lake, Washington
20km NNW of North Nenana, Alaska
23km N of North Nenana, Alaska
13km SE of Mammoth Lakes, California
65km WSW of Cape Yakataga, Alaska
125km SSE of Old Iliamna, Alaska
24km WNW of Puerto Real, Puerto Rico
8km N of Anza, CA
2km NNE of The Geysers, California
6km NW of West Bishop, California
11km NW of Rancho Cucamonga, CA
6km WSW of Huntington Beach, CA
58km E of Cape Yakataga, Alaska
39km SE of Hawthorne, Nevada
36km N of Tierras Nuevas Poniente, Puerto Rico
6km WNW of Cobb, California
12km ENE of Cloverdale, California
1km ENE of Captain Cook, Hawaii
175km SSE of Naze, Japan
147km SSE of Naze, Japan
7km WNW of Cobb, California
5km S of Volcano, Hawaii
5km S of Volcano, Hawaii
44km SSW of Ashkasham, Afghanistan
22km W of Pole Ojea, Puerto Rico
74km W of Cantwell, Alaska
8km S of Gabbs, Nevada
57km N of Valdez, Alaska
28km ESE of Redoubt Volcano, Alaska
94km ESE of Old Iliamna, Alaska
87km S of Nishinoomote, Japan
9km SSW of Idyllwild, CA
14km WNW of Anza, CA
19km ENE of Polson, Montana
22km NW of West Yellowstone, Montana
22km ESE of Anza, CA
12km NNE of Borrego Springs, CA
6km N of Cloverdale, California
62km E of Sutton-Alpine, Alaska
4km S of Encino, CA
102km N of San Juan, Puerto Rico
6km S of Salcha, Alaska
47km S of Redoubt Volcano, Alaska
17km SE of Medford, Oklahoma
18km ESE of Anza, CA
15km SE of Volcano, Hawaii
2km ENE of Choctaw, Oklahoma
2km ESE of El Centro, CA
3km SE of El Centro, CA
13km ESE of Anza, CA
162km S of Cape Yakataga, Alaska
20km NNE of Badger, Alaska
0km N of Quarry near Portola Valley, CA
28km E of Hawthorne, Nevada
42km WNW of Nikiski, Alaska
1km SW of Bonney Lake, Washington
0km NW of Entiat, Washington
4km SSE of Big Bear City, CA
14km N of Ocotillo Wells, CA
5km SE of Kelso, Washington
8km NW of Broadmoor, California
30km NNE of Charlotte Amalie, U.S. Virgin Islands
118km W of Cantwell, Alaska
9km ESE of Mammoth Lakes, California
6km S of Princeton, Canada
18km ENE of Talkeetna, Alaska
61km NW of Nikiski, Alaska
2km E of The Geysers, California
2km E of The Geysers, California
37km NNE of Amboy, Washington
9km NNW of Anza, CA
4km WNW of The Geysers, California
6km W of Cobb, California
13km ESE of Anza, CA
32km E of Shady Cove, Oregon
126km WNW of Kota Ternate, Indonesia
25km ENE of Honaunau-Napoopoo, Hawaii
5km S of Volcano, Hawaii
22km S of Neah Bay, Washington
29km N of Nikiski, Alaska
77km NE of Diego de Almagro, Chile
3km NNW of The Geysers, California
17km E of Santa Margarita, California
33km NW of Fairview, Oklahoma
8km NW of The Geysers, California
12km NNW of Caliente, Nevada
14km SE of El Valle, Dominican Republic
22km ESE of Anza, CA
84km WNW of Talkeetna, Alaska
20km ESE of Anza, CA
26km ENE of Soledad, California
252km NE of Kuril'sk, Russia
8km W of Townsend, Montana
18km ESE of Anza, CA
10km W of Volcano, Hawaii
5km NE of Edmond, Oklahoma
2km SSE of Aguanga, CA
3km W of Cobb, California
85km W of Willow, Alaska

In [166]:
states = []
for earthquake in data['features']:
    place = earthquake['properties']['place']
    # Split on comma space, otherwise we have
    # extra whitespace (a.k.a. spaces)
    edited_place = place.replace(" CA", " California")
    results = edited_place.split(", ")
    #print(results)
    # Make sure it has two segments
    if len(results) > 1:
        state_name = results[1]
        #if state_name == "CA":
        #    states.append("California")
        #else:
        #    states.append(state_name)
        states.append(state_name)
        #print(results[1])
#    states.append(place)
    #print(earthquake['properties']['place'])
states
from collections import Counter
counts = Counter(states)
counts.most_common(3)


Out[166]:
[('California', 71), ('Alaska', 45), ('Hawaii', 8)]

In [ ]:


In [ ]: