Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- #----------------------------------------------------------------------------
- # Created by : Alain Van Kerckhoven
- # Created Date: 13 juillet 2016
- # Licence : GPL
- # Version : 1.0
- # ---------------------------------------------------------------------------
- """
- Compte les lettres, les voyelles et les mots d'une phrase.
- """
- # ---------------------------------------------------------------------------
- def vowel_count(str):
- count = 0
- vowel = set("aàâäeéèêëioöuüùAEIOU")
- for alphabet in str:
- if alphabet in vowel:
- count = count + 1
- return (count)
- def words_count(str):
- prec = " "
- nb_mots = 0
- for char in str:
- nb_mots = nb_mots + int(prec == " " and char != " ")
- prec = char
- return (nb_mots)
- phrase = input("Entrez un texte à analyser : ")
- nbcar = len(phrase)
- nbvowel = vowel_count(phrase)
- nbwords = words_count(phrase)
- print("Nb de caractères :", nbcar)
- print("Nb de voyelles :", nbvowel)
- print("Nb de mots :", nbwords)
Advertisement
Add Comment
Please, Sign In to add comment