Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions python/exercise1/vowel_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

def num_vowels(text):
"""Return the number of vowels in string."""
vowels = "aeiou"
vowels = "aeiouy"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend defining the vowels outside of the num_vowels() and num_consonants() functions since you are defining this twice (DRY principle). Also, I'm curious, is "y" considered a vowel?

num = 0
for v in vowels:
num += text.lower().count(v)
return num

def num_consonants(text):
vowels = "aeiou"
vowels = "aeiouy"
num = 0
for letter in text:
if letter not in vowels:
print("consonant", letter)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be mistaken, but do you still want something printed out when the function is called?

num += text.lower().count(letter)
return num

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

Expand Down