samedi 4 avril 2020

I am trying to underline a word in if statement python3

def translate(phrase):
    translation = ""
    verb = "eau"
    print(translation)
    for letter in phrase:
        if letter.lower() in verb:
            if letter.isupper():
                translation = translation + " \u0332"
            else:
                translation = translation + " \u0332"
        else:
            translation = translation + letter

    return translation


print(translate(input("Enter a phrase: ")))

I am trying to make it so if it finds the word "eau" together (not if "a" or "e" is alone) it will underline it but the problem is that it just deletes it and then adds a underline

Enter a phrase: MEAU

M ̲ ̲ ̲

I do not only want it for "eau" i want to do it for others like if i add more word("eim") into the verb.

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire