Guided project: profitable app

Hi, I’m trying to sort the result for the most common app by genres by turn the data into a library then into a tuple and using sort function but it not working out, could someone help me please?
The code:

for genre in genres_ios:
    total = 0
    len_total = 0
    genre_table = {}
    for app in free_ios:
        genre_app = app[-5]
        if genre == genre_app:
            n_ratings = float(app[5])
            total += n_ratings
            len_total += 1
    avg_n_ratings = total/ len_total
    print(genre, ':' , avg_n_ratings)

This code will print off genre and rating one by one. What I tried to do (continued from the last line above)

for genre in genres_ios:
genre_table = {}
genre_table[genre] = avg_n_ratings
table_display = []
    for key in genre_table:
        key_val_as_tuple = (genre_table[key], key)

    table_sorted = sorted(table_display, reverse = True)
    for entry in table_sorted:
        print(entry[1], ':', entry[0])
1 Like

Hi @minhha3806 ,

I would like to take a look at your Guided Project, please click the Download button at the top of the Jupyter Notebook interface in our platform.


This will download a .tar file which contains both your notebook file and the required datasets. Please send me this .tar file.