Troubles with writing code in Step 11 in Dictionaries and Frequency tables

Screen Link:
https://app.dataquest.io/m/314/dictionaries-and-frequency-tables/11/keeping-the-dictionaries-separate

My Code:

for key in content_ratings:
    proportion = content_ratings[key] / total_number_of_apps
    c_rating_proportions[key] = proportion
    
c_rating_percentages = {} 
for key in c_rating_proportions:
    percentages = c_rating_proportions[key] * 100 
    c_rating_percentages[key] = percentages
Replace this line with your code

What I expected to happen:

My code was almost 100% identical to the answer, so I expected to move to the next step in this mission.

What actually happened:

The system would not let me move to the next step with the message: “Your code doesn’t seem to have the correct side-effects. Please re-check the instructions and your code.”

Now I do not understand why this happens, because I tried to change my code several times and at the end I have pretty much copied the answer. But still, the system would not let me move forward. How is this possible?! Am I missing anything here?

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." 

<!--Enter other details below: -->

Hi @ntokoldoshev
The reason behind the issue is ; you’ve not created the dictionary for storing proportions. There should be empty dictionary with variable c_ratings_proportions followed by the code for storing proportions values.

c_ratings_proportions = {}
for key in content_ratings:
proportion = content_ratings[key] / total_number_of_apps
c_ratings_proportions[key] = proportion

like wise, it should be same for percentages as well.

c_ratings_percentages = {}
for key in c_ratings_proportions:
percentage = c_ratings_proportions[key] * 100
c_ratings_percentages[key] = percentage

I believe this will resolve your issue. Kindly let me know the status.

Best
Kalyan

Hi,

Thanks for your message. However, this is not the reason, Please, see the screenshot. As you can see, I DID create empty dictionaries for both - proportions and percentages. And the code runs with no errors, but once I try to move forward it keeps popping up this message.

In any case, thanks for your feedback!

Regards,

Nurbek

Hey!
I see some syntax issues in the above screen especially when you are dividing the values of proportion and percentages.
your total_number_of_apps is in another line of code[7] which is not catching the division operation for the proportion calculation which is in line [6]
They both should be in same line. Please see the below code for your reference.
c_ratings_proportions = {}
for key in content_ratings:
proportion = content_ratings[key] / total_number_of_apps
c_ratings_proportions[key] = proportion
Like wise, you should also do the same for percentages as well. I believe this will resolve the side effects of code.
Let me know if you need any further help.
Cheers
Kalyan!

1 Like