Conversation
There was a problem hiding this comment.
Addresses pieces of Issue #9
good updates, more work needed.
Especially check the num_consonants logic
I would suggest testing it with more complex strings of text including strange characters like
, and capital letters, both vowels & consonants
additional features:
- output the results
- move vowels so they aren't defined in two different places
- add description of what the code does at the top
| def num_vowels(text): | ||
| """Return the number of vowels in string.""" | ||
| vowels = "aeiou" | ||
| vowels = "aeiouy" |
There was a problem hiding this comment.
consider moving vowels outside of the function so you don't have to update it each time
| for letter in text: | ||
| if letter not in vowels: | ||
| print("consonant", letter) | ||
| num += text.lower().count(letter) |
There was a problem hiding this comment.
perhaps move .lower() to line 14 so it works on the vowels also
Also, should handle numbers & other characters separately. Currently, &, I, and 2 would all be counted by this function, though they are not consonants
| return num | ||
|
|
||
| text = str(input("Enter a sentence: ")) | ||
|
|
There was a problem hiding this comment.
consider having an output option to display the number of vowels & consonants
LauraSchoenhals
left a comment
There was a problem hiding this comment.
Must fix logic in num_consonants before submitting
Description
Added some comments explaining the code.
Fixed the consonant printing.
Improved the message that is printed out.
Tested with the following strings:
Fixes issue
Fixes #9 python