def build_frecuency_table(corpus):
frequency_table = {} #initialise the dictionary
for element in corpus:
if element in frequency_table.keys(): #if the element is already in the dictionary add 1 to the value of the key
frequency_table[element] += 1
pass #when we increase the value of the counter of the key, we pass to the next word
else: #if we don't have the element in the dictionary we create a new one and initialise the counter
frequency_table[element] = 1
return frequency_table
Really nice job with this function! I just wanted to point out that we don't need pass in this function. Usually, pass is used as a placeholder to avoid implementing a function. In this case, we can just remove it from our function -- the logic of the if - else statement will ensure that an element is not unnecessarily reset to 1.
In any case, this is just a suggestion; have pass in this function does no harm!
Really nice job with this function! I just wanted to point out that we don't need
passin this function. Usually,passis used as a placeholder to avoid implementing a function. In this case, we can just remove it from our function -- the logic of theif - elsestatement will ensure that an element is not unnecessarily reset to 1.In any case, this is just a suggestion; have
passin this function does no harm!