Count Vowels in String
Advanced
Count Vowels in a String
Let's help you master counting vowels in any given string! Vowels are the 'a', 'e', 'i', 'o', 'u' sounds that we often see in words. For this challenge, you are going to write a function that counts all the vowels in a string.
How It Works
You need to create a function count_vowels(s: str) -> int that takes a single string as its input and returns the number of vowels (a, e, i, o, u) present in the string. Your function should be case insensitive, meaning that 'A' should be counted as 'a', 'E' as 'e', and so on.
Examples
Here's what the function should return for different inputs:
count_vowels("hello world") # Returns: 3 count_vowels("Python") # Returns: 1 count_vowels("AEIOU") # Returns: 5 count_vowels("") # Returns: 0
Happy coding! Find all those vowels and practice your string manipulation skills!
Inputs
Arg 1:
"hello world"Expected Output
3Actual Output