Jump to content

informatique ;) *** semaine 4 chercher remplacer


Vaiana
Go to solution Solved by Sans-Visage,

Recommended Posts

  • Ancien du Bureau

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"

Link to comment
Share on other sites

  • Ancien du Bureau
  • Solution

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 :')))

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...