Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise 1 python. #8

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
12 changes: 7 additions & 5 deletions python/exercise1/vowel_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

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"
consonants= "bcdfghjklmnpqrstvwxz"
num = 0
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
for letter in text:
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
if letter not in vowels:
print("consonant", letter)
num1 += text.lower().count(c)
return num
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved

text = str(input("Enter a sentence: "))

print("Number of vowels", num_vowels(text))
print("Number of consonants", num_consonants(text))
print("Number of vowels", num_vowels(text))
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
sanyatonwu marked this conversation as resolved.
Show resolved Hide resolved
print("Number of consonants", num_consonants(text))

Expand Down