Skip to content
14 changes: 8 additions & 6 deletions python/exercise1/vowel_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))