← Back to challenges

Extending The String

PythonHardlanguage_fundamentalsregexstrings

Instructions

Make two functions:

  1. consonants(word) which returns the number of consonants in a word when called.
  2. vowels(word) which returns the number of vowels in a word when called.

Examples

vowels('Jameel SAEB') ➞ 5

consonants('He|\o mY Fr*end') ➞ 7

consonants("Smithsonian") ➞ 7
vowels("Smithsonian") ➞ 4

Notes

  • Vowels are: a, e, i, o, u.
  • Spaces and special characters count neither as consonants nor as vowels.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Count Number of Instances