Vowel Counter Map
A dictionary is a good tool when you need a separate counter for each character. Write a function vowel_counts that takes a string s and counts how many times the vowels a, e, i, o, and u appear. Letter case does not matter: A and a count as the same vowel. Return a dictionary with all five vowels, even if some of them appear 0 times.
Примеры
Ввод
"hello"Вывод
{"a": 0, "e": 1, "i": 0, "o": 1, "u": 0}Ввод
"AEIOU"Вывод
{"a": 1, "e": 1, "i": 1, "o": 1, "u": 1}Ввод
""Вывод
{"a": 0, "e": 0, "i": 0, "o": 0, "u": 0}Нужно реализовать
def vowel_counts(s: str) -> dict:
Теги
stringsdicthashmap
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
"hello"Expected
{"a":0,"e":1,"i":0,"o":1,"u":0}2
Input
"AEIOU"Expected
{"a":1,"e":1,"i":1,"o":1,"u":1}3
Input
""Expected
{"a":0,"e":0,"i":0,"o":0,"u":0}4
Input
"banana"Expected
{"a":3,"e":0,"i":0,"o":0,"u":0}5
Input
"xyz"Expected
{"a":0,"e":0,"i":0,"o":0,"u":0}6
Input
"ab"Expected
{"a":1,"e":0,"i":0,"o":0,"u":0}Focus radio
Paused · SomaFM · Fluid