I don't understand a dictionary & if statement

I have a question about creating a dictionary.
“if value in frequency_table::”
regarding above specific code, I don’t understand why there’s value in frequency_table…
because frequency_table was empty {} and we didn’t append anything in this frequency_table, so why can we find “value” in “frequency_table” in this if statement?

My Code:

def freq_table(index):
    frequency_table = {}
    for row in apps_data[1:]:
        value = row[index]
        if value in frequency_table:
            frequency_table[value] += 1
        else:
            frequency_table[value] = 1
            
    return frequency_table
1 Like

Hi @kanae.iwase

I found these two similar posts:

There are many more posts within the DQ community, that can help you understand this.
Let us know if you are still unsure.

2 Likes

Thank you! I found answer in this link!
I didn’t know how to search this question because I don’t even understand where I was struggling with …
Thank you again Rucha san!

2 Likes