Confusion With Python Dictionary Code

Screen Link:

My Code:

content_ratings = {'4+': 4433, '12+': 1155, '9+': 987, '17+': 622}
total_number_of_apps = 7197
c_ratings_percentage = {}
c_ratings_proportion = {}

for rating in content_ratings:
    porportion = content_ratings[rating] / total_number_of_apps
    percentage = porportion * 100
    c_ratings_porportion[rating] = porportion
    c_ratings_percentage[rating] = percentage

What I expected to happen:
Find the porportiosn and percentages in the list

What actually happened:
it says their was an error

Replace this line with the output/error

Your code doesn’t seem to have the correct side-effects. Please re-check the instructions and your code.”

It’s because of small typos in your code -


Above, you use pROportion

Everywhere else, you are using pORportion.

Fixing those typos should resolve the error. Although, ideally, you should have received an error corresponding to the typo. I am not sure why that didn’t happen. But I tried your code after fixing the typos and was able to Submit and pass.

1 Like