Ancien du Bureau Vaiana Posted February 5, 2021 Ancien du Bureau Share Posted February 5, 2021 Bon salut, alors je suis déterminée à achever ce programme là J'ai une erreur ligne 13 dans mon programme, je ne comprends pas from printer import * motif = input() remplacer = input() texte = input() resultat= "" Posdepart = 0 while len(texte) > Posdepart: if len(motif) + Posdepart > len(texte): Estidentique = True for pos in range(len(motif)): if motif[pos] != texte[Posdepart + pos]: Estidentique = False if Estidentique : resultat += remplacer Posdepart= Posedepart + len(motif) else: resultat += texte[Posdepart] Posdepart += 1 print(resultat) Merci Ca me met "Estidentique is not defined" Quote Link to comment Share on other sites More sharing options...
Ancien du Bureau Solution Sans-Visage Posted February 5, 2021 Ancien du Bureau Solution Share Posted February 5, 2021 Coucou, Essaies de mettre " for pos in range(len(motif)): if motif[pos] != texte[Posdepart + pos]: Estidentique = False if Estidentique : resultat += remplacer Posdepart= Posedepart + len(motif) else: resultat += texte[Posdepart] Posdepart += 1 " Tout ca avec un alinéat après if len(motif) + Posdepart > len(texte): Estidentique = True Tu vois ce que je veux dire ? Genre il faut décaler tout ça from printer import * motif = input() remplacer = input() texte = input() resultat= "" Posdepart = 0 while len(texte) > Posdepart: if len(motif) + Posdepart > len(texte): Estidentique = True for pos in range(len(motif)): if motif[pos] != texte[Posdepart + pos]: Estidentique = False if Estidentique : resultat += remplacer Posdepart= Posedepart + len(motif) else: resultat += texte[Posdepart] Posdepart += 1 print(resultat) Dis moi si ça marche ? (Et si tu peux aussi stp, c'est plus simple quand tu postes un screen de ton algo stp, parce que du coup il y a les couleurs et les lignes :'))) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.