Answer the question
In order to leave comments, you need to log in
Why are my items not being removed from the list?
There is this code:
text_to_transform = ['(Это) ', '(те)@(стовый) ', '(тек)@(ст)']
for x in text_to_transform:
if '@' in x:
text_to_transform.remove(x)
print(text_to_transform)
['(Это) ', '(тек)@(ст)']
( (тек)@(ст) )
'(Это)'
Answer the question
In order to leave comments, you need to log in
You are iterating the list and editing it at the same time. Do not do it this way. At least here:
for x in text_to_transform.copy():
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question