Guided project; apple + google store data set analysis

I’m at the point where I have to add up the total user reviews for a genre, but I keep getting a divide by zero error for genre_len, which tells me that the ‘if app_genre == genre:’ isn’t resolving the way I need it to.

a_data_freq = freq_table(a_data_free, -5)

for genre in a_data_freq:
    total = 0
    genre_len = 0
    for app in a_data_free:
        app_genre = app[-5]
        if app_genre == genre:
            n_ratings = float(app[5])
            total += n_ratings
            genre_len += 1
        n_ratings_avg = total / genre_len
        print(genre, ':', n_ratings_avg)   

Your code seems to be correct. I think you have made any mistakes in previous cells. Or do one thing, maybe it will work restart the kernel and run all cells.

okay, so, the online project has been lost, so I had to open the downloaded backup. running it from the start fixed it.

2 Likes