CMU Coding Bootcamp
at main 477 B view raw
1def vowelCount(s: str) -> int: 2 """Count the number of vowels (a, e, i, o, u) in a string.""" 3 s = s.lower() 4 return s.count("a") + s.count("e") + s.count("i") + s.count("o") + s.count("u") 5 6 7print("Testing vowelCount()...", end="") 8assert vowelCount("Abc def!!! a? yzyzyz!") == 3 9assert vowelCount("Hi! How are you?") == 6 10assert vowelCount("AAAEEEiOL") == 8 11assert vowelCount("Rhythm") == 0 12assert vowelCount("WHY, TRY SHY FLY RHYTHMS SLYLY.") == 0 13print("Passed!")