From 3972ed80a9155ba5a1c1c332acb116c93b3dec68 Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 15 Dec 2023 10:38:56 -0500 Subject: [PATCH 1/2] add y to vowels --- python/exercise1/vowel_counter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/exercise1/vowel_counter.py b/python/exercise1/vowel_counter.py index a50949a..9650355 100644 --- a/python/exercise1/vowel_counter.py +++ b/python/exercise1/vowel_counter.py @@ -2,14 +2,14 @@ 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" + vowels = "aeiouy" for letter in text: if letter not in vowels: print("consonant", letter) From 090a4c311d18d48e20e28c2e02f6f82740e7a6dd Mon Sep 17 00:00:00 2001 From: Helen Kershaw Date: Fri, 15 Dec 2023 10:54:43 -0500 Subject: [PATCH 2/2] return count of consontants rather than printing the consonant. --- python/exercise1/vowel_counter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/exercise1/vowel_counter.py b/python/exercise1/vowel_counter.py index 9650355..8aaf9da 100644 --- a/python/exercise1/vowel_counter.py +++ b/python/exercise1/vowel_counter.py @@ -10,9 +10,11 @@ def num_vowels(text): def num_consonants(text): vowels = "aeiouy" + num = 0 for letter in text: if letter not in vowels: - print("consonant", letter) + num += text.lower().count(letter) + return num text = str(input("Enter a sentence: "))