-
Notifications
You must be signed in to change notification settings - Fork 0
Exercise 1 python. #10
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?
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider having an output option to display the number of vowels & consonants
LauraSchoenhals
left a comment
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.
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