Tally Vowels and Consonants Separately

Easy ⏱ 8 min 82% acceptance ★★★★★ 4.8
Write vowel_consonant_count(s) that returns a tuple (vowels, consonants) counting how many alphabetic characters in s are vowels (a, e, i, o, u, case-insensitive) versus consonants. Ignore digits, spaces and punctuation entirely.

Examples

Example 1
Input
s = 'Hello World'
Output
(3, 7)
Explanation

Vowels: e, o, o = 3. Consonants: H, l, l, W, r, l, d = 7. The space is ignored.

Constraints

  • 0 <= len(s) <= 10^4

Topics

StringsCharacter Frequency

Companies

AccentureDeloitte

Hints

Hint 1

Lowercase the string first to make the vowel check case-insensitive.

Hint 2

Use `str.isalpha()` to skip non-letters.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.