Step 13/15 - Could we loop through the 'n_user_ratings' list in the second 'for' loop instead of apps_data[1:]?

Screen Link:

We created a list (‘n_user_ratings’) containing data from the ‘rating_count_tot’ column:

n_user_ratings = []
for row in apps_data[1:]:
    rating = float(row[5])
min_rating = min(n_user_ratings)
max_rating = max(n_user_ratings)

Then further down in the 2nd loop, the provided answer suggests we loop through the apps_data[1:] dataset again and re-define that the rating is int/float of row[5]…

for row in apps_data[1:]:
    user_ratings = int(row[5])
    if user_ratings <= 10000:
        user_ratings_freq['0 - 10000'] += 1

…instead of looping through the n_user_ratings list we created earlier:

for rating in n_user_ratings:
    if rating <= 1000:
        rating_count_intervals['0 - 1000'] += 1

The output I got was the same between the two scenarios.
I thought using the ‘n_user_ratings’ list would be slightly more efficient, since we’ve already created it. Is there a reason why it’s better to loop through apps_data instead or is it just a different way of doing the same thing? :space_invader:

Click here to open the screen in a new tab.

1 Like

Yes i would agree with you. I didn’t see any potential benefits of using apps_data in second loop when we already have n_user_ratings.


Thank you very much!! :star: :slightly_smiling_face:

1 Like