I have tried many possible solutions but none of them worked. My code is a simple word counter that counts the frequency of words in song lyrics. Since short words should’t be counted I wrote this code. My word and their count lists look like this.
goodwords=("a", "my", "the", "I", "long", "up", "on") count=(26, 16, 16, 15, 12, 11, 11 )
So I wrote this code to filter out short words.
for word in goodwords: if len(word)<3: goodwords.index(word) count.remove(goodwords.index(word)) goodwords.remove(word)
Python throws me this error:
ValueError: list.remove(x): x not in list
Even when I try to assign the index of the word to an int the same error is shown.