re: Daily Challenge #3 - Vowel Counter VIEW POST

FULL DISCUSSION
 

Python

Given the list :

vowels = ['a', 'e', 'i', 'o', 'u']

We can define a function:

def vowels_count(word):
    count = 0
    for vowel in vowels:
        count += word.lower().count(vowel)
    return count

Or simply in a one-liner:

vowel_count = lambda word: len([char for char in word if char in vowels])
code of conduct - report abuse