# Dictionaries and keys in for loop

Hi guys,

I do not quite understand what is happening here.

content_ratings = {‘4+’: 4433, ‘12+’: 1155, ‘9+’: 987, ‘17+’: 622}
total_number_of_apps = 7197

c_ratings_proportions = {}
c_ratings_percentages = {}

for each in content_ratings:
proportion = content_ratings[each] / total_number_of_apps
c_ratings_proportions[each] = proportion
c_ratings_percentages[each] = c_ratings_proportions[each]*100
print(c_ratings_proportions)
print(c_ratings_percentages)

We created this c_ratings_proportions dictionary and we defined proportion within the for loop. However, how does the program assign keys to the c_ratings_proportion. We just tell it to pull proportions from the proportion variable we defined, nothing more.

Hey @furkan.demirdoven
I am not sure if i understand your question right. Could you elaborate.
Thanks
Raj

This is how we tell the dictionary what key is key and this is how we tell it what to assign as a value to the same key. for every loop run `each` substitutes the value like:
In 1st loop - `each = "4+"`
In 2nd loop - `each = “12+” and so on.

hope that helps.