-
Notifications
You must be signed in to change notification settings - Fork 0
Exercise 1 python. #9
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,17 +2,19 @@ | |
|
|
||
| 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): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: ")) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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