I’m on this section: https://app.dataquest.io/m/314/dictionaries-and-frequency-tables/8/finding-the-unique-values
And I saw this example but don’t really understand the purpose of it.
https://s3.amazonaws.com/dq-content/314/py1m4_cb19.svg
If the 12+ exists already why do we need a +1 in this case? I understand we’re counting it in this case but why is the “else” needed here? Won’t the original code do the same thing without the else.
also here is my code for this problem:
content_ratings =
for row in apps_data[1:]:
c_rating in row[10]
if c_rating in content_ratings:
content_ratings[c_rating] += 1
else:
content_ratings[c_rating] = 1
print(content_ratings)
how come i’m getting the error: TypeError: list indices must be integers, not str
comparing my code to the answer i can see the difference but can somebody explain this to me further?
for one why is content_ratings = {} instead of
and another c_rating = row[10] instead of in