Guided project: Profitable App profiles for App store and Google Play store

Hello,
I’m bit confused with this code and how it works:

reviews_max = {}

for app in android:
name = app[0]
n_reviews = float(app[3])

if name in reviews_max and reviews_max[name] < n_reviews:
    reviews_max[name] = n_reviews
    
elif name not in reviews_max:
    reviews_max[name] = n_reviews

In the code above, What happens if name in reviews_max and reviews_max[name] == n_reviews?

If the reviews_max dictionary holds the maximum reviews for each unique app, why do we have duplicate apps with the same maximum review in the dictionary?

Also why is the list length of android_clean same with the unique apps length, despite removing the duplicate rows?

Why are the lenghts of reviews_max and android_clean same after deleting the duplicate entries?

Please help me out guys. I need some explanation how this all works

hi @smartychiz

Let’s first start with the code you have highlighted. this has been answered here

next about the unique apps and android clean list being equal in length, we would need further info to debug that. you may look at these posts if they are helpful to you.

If not, please share your notebook using this post so that we can check the actual problematic code.

Thanks a lot. I have gone through the solution links you shared. The code is clear to me now. Thanks

1 Like