0

I have tried this piece of code but I don't understand why the word 'Folgerung / Empfehlung \n ' does not get deleted and if I try the for loop a second time it got deleted. I am pretty confused

headers_strings= ["Vorgang \n ","Ergebnisse \n ","Ergebnisse / Folgerung \n ","Folgerung / Empfehlung \n ","Einzelheiten \n ","Einzelergebnisse \n "]
    
l=['Vorgang \n TEST \n ','Ergebnisse \n ', 'Folgerung / Empfehlung \n ', 'Einzelheiten \n ']
    
for i in l :
    if i in headers_strings:
        l.remove(i)
        
print(l)

the output is :

['Vorgang \n TEST \n ', 'Folgerung / Empfehlung \n ']
wjandrea
  • 28,235
  • 9
  • 60
  • 81
Yafaa Ben Tili
  • 176
  • 1
  • 7

0 Answers0