Short 1 count of data? - Python Dictionaries and Frequency tables (slide 9/11)

My Code:
frequency_rating = {‘0 - 500000’: 0, ‘500000 - 1000000’:0, ‘1000000 - 1500000’:0, ‘1500000 - 2000000’:0, ‘2000000+’:0}

for row in apps_data [1:]:
rating_count_tot = float(row[5])
if rating_count_tot <= 500000:
frequency_rating[‘0 - 500000’] += 1
elif 500000 < rating_count_tot <= 1000000:
frequency_rating[‘500000 - 1000000’] += 1
elif 1000000 < rating_count_tot <= 1500000:
frequency_rating[‘1000000 - 1500000’] =+ 1
elif 1500000 < rating_count_tot <= 2000000:
frequency_rating[‘1500000 - 2000000’] += 1
elif rating_count_tot > 2000000:
frequency_rating[‘2000000+’] += 1

print (frequency_rating)
print (7175 + 16 + 1 + 1 + 3)
print (len(apps_data[1:]))

**Results:**
{'0 - 500000': 7175, '500000 - 1000000': 16, '1000000 - 1500000': 1, '1500000 - 2000000': 1, '2000000+': 3}
7196
7197

It looks good to me but when I total the numbers, I got 7196 instead of expected 7197. I can't figure out what happened to short 1. Since the challenge is to come up with our own intervals, mine is different than the provided answer. I copied the provided answered and ran it to indeed 7197.  
Thank you!

Hey @snicks.pnht

Welcome to Dataquest! For your future posts please attach the link to the course content and also tag the course/lesson you are facing the confusion at. For more details please refer to Guidelines for asking a technical question in our Community - Announcements & Guidelines - Dataquest Community

For now, the below code is the bugged one! Since you have written it as =+ it overrides any count present for this key-value combination. So only the last iteration is valid and hence only rating is counted for this category!

Let me know if this helps. Happy learning!

2 Likes

Hi @snicks.pnht,

Please fix also this typo: += instead of =+.

1 Like

Thank you! I kept starring at it and can’t see the mixed up. I appreciate the help and will do for future course questions.

1 Like

Thank you for your help. I see it now. I appreciate the response!

1 Like