Strings · Beginner · 45 XP · about 5 min
Write a function called count_vowels(s) that counts the number of vowels (a, e, i, o, u) in a string.
The function should be case-insensitive (both 'A' and 'a' count as vowels).
count_vowels("hello") # Returns 2 count_vowels("AEIOU") # Returns 5 count_vowels("rhythm") # Returns 0 count_vowels("Beautiful") # Returns 5
Ready?
Accept the challenge to start writing. A small timer counts the time this page is in view.
Output appears here.