Skip to content

Instantly share code, notes, and snippets.

@GravenilvecTV
Created November 24, 2018 19:14
Show Gist options
  • Save GravenilvecTV/cffb394f17b252b86a0d52331b0049b4 to your computer and use it in GitHub Desktop.
Save GravenilvecTV/cffb394f17b252b86a0d52331b0049b4 to your computer and use it in GitHub Desktop.
APPRENDRE LE PYTHON #6 ? LES FONCTIONS
# tp : une fonction pour calculer le nombre de voyelles dans un mot
# definir une fonction get_vowels_numbers(mot)
def get_voyels_number(word):
# créer un compteur de voyelles
nb_vowels = 0
# pour chaque lettre du mot vous verifiez s'il s'agit d'un voyelle
for letter in ['a','e','i','o','u','y']:
# si c'est le cas
if letter i in vowels:
# on ajoute un au compteur
nb_vowels += 1
# à la fin de la fonction, vous allez renvoyer le compteur
return nb_vowels
word = input("Entrer un mot")
vowels_count = get_vowels_numbers(mot)
print("Il y a ", vowels_count, "dans le mot", word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment