Profitable App Profiles for the App Store - Guided Project

Screen Link:

https://app.dataquest.io/m/428/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/12/most-popular-apps-by-genre-on-the-app-store
My Code:

total = 0
len_genre = 0
genres_ios = freq_table(ios_final, -5)

for genre in genres_ios:
    total = 0
    len_genre = 0
    for app in ios_final:
        genre_app = app[-5]
        if genre_app == genre:            
            n_ratings = float(app[5])
            total += n_ratings
            len_genre += 1
    avg_n_ratings = total / len_genre
    print(genre, ':', avg_n_ratings)

What I expected to happen:

Social Networking : 71548.34905660378
Photo & Video : 28441.54375
Games : 22788.6696905016
Music : 57326.530303030304
Reference : 74942.11111111111
Health & Fitness : 23298.015384615384
Weather : 52279.892857142855
Utilities : 18684.456790123455
Travel : 28243.8
Shopping : 26919.690476190477
News : 21248.023255813954
Navigation : 86090.33333333333
Lifestyle : 16485.764705882353
Entertainment : 14029.830708661417
Food & Drink : 33333.92307692308
Sports : 23008.898550724636
Book : 39758.5
Finance : 31467.944444444445
Education : 7003.983050847458
Productivity : 21028.410714285714
Business : 7491.117647058823
Catalogs : 4004.0
Medical : 612.0

What actually happened:
Medical : 2974676.0
Medical: 2568117.0
Medical: 2422346.333

Replace this line with the output/error

I can’t understand how the DQ code generates that result (from the DQ solution). When I run the code I get Medical…(see above)

Can someone please tell me what I’m not seeing here ? Thanks

Please share full notebook code. You can refer this guideline to how to share your project notebook.