import os print(os.listdir("data/Textes")) with open("data/Textes/palindrome.txt","r",\ encoding="UTF8") as f : texte = f.read() print("Texte de",len(texte),"caractères") print(texte[:100]) # Début du texte print(texte[-100:]) # Fin du texte # Début et fin effectives du palindrome debut = texte.index("T") fin = texte.index("# G") # Détection des ponctuations et des caractères accentués texte = texte[debut:fin].lower() L1 = list(set([ c for c in texte if c < "a" ])) print(L1) L2 = list(set([ c for c in texte if c > "z" ])) L2.sort() print(L2) for c in L1 : # Nettoyage texte = texte.replace(c,"") for old,new in [('à','a'), ('â','a'), ('ç',"c"), \ ('è',"e"), ('é',"e"), ('ê',"e"), \ ('ë',"e"), ('ï',"i"), ('ô',"o")] : texte = texte.replace(old,new) print("Vérification :",texte == texte[::-1])