Fail to extract the max value

My Code:

googlereview_max = {}
for app in google_data:
    name = app[0]
    n_reviews = float(app[3])  
    if name in review_max and review_max[name]< n_reviews:
        googlereview_max[name] = n_reviews
    elif name not in review_max:
        googlereview_max[name] = n_reviews 

What I expected to happen:
the review_max list should extract the max value. For example if I print review_max[‘Blood Pressure Log - MyDiary’], I should get 8348 as 8348 is the correct max max value in the csv file itself

What actually happened:
I get 8347.

Hi @1047035425 : Please provide a mission link and tag the topic as per these guidelines so that we can better assist you.

Hi @1047035425,

Welcome to the DQ Comunity! :grinning:
It’s not exactly the answer to your question, but why in your code the dictionary initially is called googlereview_max and then you call it review_max in the if-statement?

1 Like

I thought the instructions told us not to use an elif statement?

No, no, it told us didn’t use else statement, because the number of reviews will be incorrectly updated.
elif will be the right decision.

1 Like

Already clarified here. Will close this topic to avoid further confusion.

2 Likes