Skip to main content

Vowels and Consonants

Problem Description​

Given a string in English, return a tuple containing the number of vowels and consonants.

Tip: Vowels are the letters A, E, I, O, and U; consonants are the letters B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z.

Input​

  • A single string.

Output​

  • A tuple containing two integers: the number of vowels and the number of consonants.

Constraints​

  • The function should ignore case when counting vowels and consonants.
  • Non-alphabet characters should be ignored.

Example​

Input:
"Swift Coding Challenges"

Output:
(6, 15)

Explanation:
The string "Swift Coding Challenges" contains 6 vowels (i, o, i, a, e, e) and 15 consonants (S, w, f, t, C, d, n, g, C, h, l, l, n, g, s).

Input:
"Mississippi"

Output:
(4, 7)

Explanation:
The string "Mississippi" contains 4 vowels (i, i, i, i) and 7 consonants (M, s, s, s, s, p, p).