I'm doing a function to count the words of a text without repeating them and with that, I also need to count how many times it appears inside this list of strings I used the code below but it does not work, I can not get the position of the word in my list of words to refer to in another list I will only store the amount of times it appears. Note: I need this to respect the position of the word with reference to the position. Ex: words [1] = 'house' frequency [1] = 3
Frequency (Tweets list):
palavras = []
freq_palavras = []
for x in range(len(listaTweets)):
tweet = listaTweets[x]
listaP = separa_palavras(tweet)
for p in listaP:
if p in palavras:
indice = palavras.index(p)
freq_palavras[indice] += 1
else:
palavras.append(p)
return palavras, freq_palavras