There is a problem with removing successive elements from a list. For example I have an list;
['aaaaa', '@someword', '@otherword','bbbb',...]
I want remove from list elements that has @ char.
a = ['aaaaa', '@someword', '@otherword','bbbb']
for word in a:
if '@' in word:
print("found @ in word :" +word)
a.remove(word)
The output is; (found only first element, skipped second one.)
found @ in word :@someword
if I add some value between this element;
a = ['aaaaa', '@someword', 'qqqq', '@otherword','bbbb']
It catch two of them;
found @ in word :@someword
found @ in word :@otherword
I debug the code, if there are succesive somewords which include @ char, remove function skip the second one, because of the changing of indices after removing process.
how can i remove these words?