Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Hopefully Easy to Understand solution in Clear category for Count Vowels by BootzenKatzen
def count_vowels(text: str) -> int:
count = 0 # creating our count of vowels
for letter in text: # look at each letter
if letter in "aeiouAEIOU": # if that letter is a vowel
count += 1 # add to the count
return count # return the final count
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!")
Nov. 28, 2023
Comments: