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
Owner

Choose a reason for hiding this comment

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

y is both a consonant and value, so the definition of vowel should be clarified

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

def num_consonants(text):
Copy link
Owner

Choose a reason for hiding this comment

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

Docstrings could be added to describe what the function is doing

vowels = "aeiou"
vowels = "aeiouy"
num = 0
for letter in text:
if letter not in vowels:
print("consonant", letter)
num += text.lower().count(letter)
Copy link
Owner

Choose a reason for hiding this comment

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

What about numbers? I don't think numbers should be counted as consonants, but they were counted when I tested the script

return num

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

Expand Down