728x90
1. Problem: https://py.checkio.org/en/mission/count-vowels/
2. My solutions
def count_vowels(text: str) -> int:
# your code here
number_vowels = 0
lower_case = text.lower()
for vowel in ['a','e','o','i', 'u']:
number_vowels += [*lower_case].count(vowel)
print(number_vowels)
return number_vowels
print("Example:")
#print(count_vowels("Hello"))
# These "asserts" are used for self-checking
assert count_vowels("hello") == 2
assert count_vowels("openai") == 4
assert count_vowels("typescript") == 2
assert count_vowels("a") == 1
assert count_vowels("b") == 0
assert count_vowels("aeiou") == 5
assert count_vowels("AEIOU") == 5
assert count_vowels("The quick brown fox") == 5
assert count_vowels("Jumps over the lazy dog") == 6
assert count_vowels("") == 0
print("The mission is done! Click 'Check Solution' to earn rewards!")
728x90
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[CheckIO] Replace All Occureences (0) | 2024.02.18 |
---|---|
[CheckIO] Convert To Title case (0) | 2024.02.18 |
[Check IO] words-order (0) | 2022.02.27 |
[Check-IO] Conversion into CamelCase (0) | 2021.12.25 |
[Check-IO] Conversion from CamelCase (0) | 2021.12.20 |
댓글