# Def freq_table who can explain

Hi Team member ! i can not understand this question. how can i solve ?
def freq_table(n):
c={}
for row in apps_data[1:]:
value=row[n]
if value in c:
c[row]+=1
else:
c[row]=1
genres_ft=freq_table()

https://app.dataquest.io/m/315/functions%3A-fundamentals/7/creating-frequency-tables

Hi! @rrahmanjanov
Welcome to the community!
Can you please be a bit more specific to the question?
It will be great if you refer here and here regarding questions formatting.

Thank you!

1 Like

Your function `freq_table` takes a list as input. It intends to count the number of items in the list and return these as a frequency table. For example `alist = ['cat', 'bird', 'bird', 'parrot'] will return {'cat' : 1, 'bird': 2, 'parrot': 1}`.

So you create an empty list `freq = {}`. `for key in freq` means if the item has already been counted before. ` freq[key] += 1` means increase the value by 1. `else` means it is not in the `freq dictionary` hence has not been counted before, `freq[key] = 1` set this item to a value of 1.

``````def freq_table(a_list):
freq = {}
for key in a_list:
if key in freq:
freq[key] += 1
else:
freq[key] = 1
return freq

genres_ft = freq_table(genres)
``````
1 Like

Thank you for explanation

1 Like