Try this
Hope this works
L1=[] L2=[] L3=[] L4=[] with open ("C:/Users/lveillat/Desktop/Données stage/Fichiers tests/test_retrait_chaines_intermediaire.txt","r") as f1: for lignes in f1: lignes=lignes.rstrip('\n') L1.append (lignes) L2.append (lignes) for i in L1: if i not in L4: L4.append(i) L3.append(i) else: continue for j in L2: if i in j or j in i: if i != j: L4.append(j) L3.append(j) i = j print(L3) L3.clear()
Hope this works