Dictionaries and Frequency Tables | 11.Keeping the Dictionaries Separate

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

My Code:

c_ratings_proportions[key] = proportion

Why do we have to use [key] to assign proportion to c_ratings_proportions. I understand that key:value pair has to be assigned, but I did not understand the purpose of using [key] while assigning it to another variable.

@ashwin.mvsr: if you print the value of proportion inside the loop, you will notice that at each iteration, there is a value outputted. Here we want to reference the exact key in the dictionary to insert the transformed value at (the position it was taken from before transformation), thus we use square brackets to index the particular key.

image

Hope this clarifies!