diff --git a/python/exercise1/vowel_counter.py b/python/exercise1/vowel_counter.py index a50949a..d06aaa6 100644 --- a/python/exercise1/vowel_counter.py +++ b/python/exercise1/vowel_counter.py @@ -2,21 +2,23 @@ def num_vowels(text): """Return the number of vowels in string.""" - vowels = "aeiou" + vowels = "aeiouy" num = 0 for v in vowels: num += text.lower().count(v) return num def num_consonants(text): - vowels = "aeiou" - for letter in text: - if letter not in vowels: - print("consonant", letter) + """Return the number of consonants in string.""" + consonants= "bcdfghjklmnpqrstvwxz" + num1 = 0 + for c in consonants: + num1 += text.lower().count(c) + return num1 text = str(input("Enter a sentence: ")) - print("Number of vowels", num_vowels(text)) print("Number of consonants", num_consonants(text)) +