Def freq_table who can explain

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

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
            freq[key] = 1         
    return freq

genres_ft = freq_table(genres)
1 Like

Thank you for explanation

1 Like