Count Vowels
Counts the number of vowels in a string.
- string
- vowels
- count
Code
def count_vowels(s):
vowels = 'aeiou'
return len([char for char in s.lower() if char in vowels])Usage
count_vowels('hello') # Returns: 2Counts the number of vowels in a string.
def count_vowels(s):
vowels = 'aeiou'
return len([char for char in s.lower() if char in vowels])count_vowels('hello') # Returns: 2