Solution Exercice 73: algorithme python qui permet de supprimer tous les voyelles d'une chaine

Exercice 73

Ecrire un algorithme python qui supprime toutes les voyelles d'une chaîne donnée s.
Exemple si s = "Python is hight level programming language", l'algorithme renvoie la chaîne: "Pthn s hght lvl prgrmmng lngg"

Solution





# coding: utf-8
def deleteVowels(s):
    # création de la liste des voyelles
    vowels = ['a','e','y','u','i','o']
    
    # initialisation de la chaine sans vowels
    s1 = ""
    
    # parcourir les caractères de la chaine s et élimination des voyelles  
    for x in s:
        if x not in vowels:
            s1 = s1 + x
    return s1

# Exemple
s = "Python is hight level programming language"
print(deleteVowels(s)) 
# affiche: Pthn s hght lvl prgrmmng lngg




 

 

Younes Derfoufi
CRMEF OUJDA

1 thought on “Solution Exercice 73: algorithme python qui permet de supprimer tous les voyelles d'une chaine

Leave a Reply

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock