Given a string s, return the number of vowels in the string.
Vowels are the characters 'a', 'e', 'i', 'o', 'u', in both uppercase and lowercase.
Function Signature
def count_vowels(s: str) -> int:
...
Rules
-
The ten vowel characters are
a
,
e
,
i
,
o
,
u
,
A
,
E
,
I
,
O
,
U
. The letter
y
is not a vowel.
-
Every other character (consonants, digits, spaces, punctuation) adds nothing to the count.
Constraints
-
1 <= len(s) <= 10^5
-
s
consists of printable ASCII characters.
Examples
Input: s = "hello world"
Output: 3
The vowels in "hello world" are e, o and o, so the count is 3. The space and the consonants are ignored.
Input: s = "AEIOUaeiou"
Output: 10
Every character is a vowel (5 uppercase and 5 lowercase), so the count is 10.
Input: s = "Why try?"
Output: 0
The string has no a, e, i, o or u in either case. Neither y counts, because y is not a vowel here.