Editor

Vowels and Consonants

#528 · Strings · Beginner · 25 XP · about 4 min

Write vowels_and_consonants(text) that counts the letters in text and returns a tuple (vowels, consonants).

  • The vowels are a, e, i, o and u, in upper or lower case.
  • Every other letter is a consonant, and that includes y.
  • Spaces, digits and punctuation are not letters, so they are not counted at all.

Examples

vowels_and_consonants('Hello World')  # returns (3, 7)
vowels_and_consonants('Sky 2024!')    # returns (0, 3)
vowels_and_consonants('')             # returns (0, 0)

In 'Hello World' the vowels are e, o and o, and the other 7 letters are consonants.

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.