I have a list with lenght of: 370000
. In this list i have items like: "a", "y", "Y", "q", "Q", "p", "P",
, meaning this is a list of words but from time to time i get those single characters.
I want to remove those characters from the list, i am pretty new in python but the first thing that came to my mind was to do something like:
for word in words:
if word== 'm' or word== 'y' or word== 'Y' or word== 'p' or word== 'Q' or word== 'q' or word== 'a' or word== 'uh':
words.remove(word)
In a list with 370.000 items this method is taking a loooot of time. Seriously, a lot.
Does anyone have another awesome idea on how to get a better performance?
Thanks in advance.