Skip to content

Conversation

@github-actions
Copy link

Description

Added some comments explaining the code.

Fixed the consonant printing.

Improved the message that is printed out.

Tested with the following strings:

abcdefghijklmnopqrstuvwxyz
Welcome to the Jungle 1234

Fixes issue

Fixes #9 python

Copy link
Owner

@LauraSchoenhals LauraSchoenhals left a 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:

  1. output the results
  2. move vowels so they aren't defined in two different places
  3. 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"
Copy link
Owner

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)
Copy link
Owner

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: "))

Copy link
Owner

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 LauraSchoenhals marked this pull request as draft July 17, 2024 15:39
Copy link
Owner

@LauraSchoenhals LauraSchoenhals left a 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

@LauraSchoenhals LauraSchoenhals marked this pull request as ready for review July 17, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python: Exercise 1

3 participants