Help with making sense of for loops with if statements in dictionaries

Screen Link:
(Learn data science with Python and R projects)

My Code:

content_ratings = {}
for row in apps_data[1:]:
    c_rating = row[10]
    if c_rating in content_ratings:
        content_ratings[c_rating] += 1
        content_ratings[c_rating] = 1

This code is correct but I am having a tough time wrapping my head around how it is working. Specifically how in the if statement c_ratings is being checked in the content_ratings dictionary, which is blank (as it is an empty dictionary created outside the loop). Where in this code is the content_ratings dictionary being created ? Thanks

Hello @maximlark

Kindly refer to this:

Thank you for your help. This makes sense. Much Appreciated

1 Like