re: Daily Challenge #3 - Vowel Counter VIEW POST


My python solution!

def count_vowels(word):
    return len(l for l in word if l in "aeiou")

What if the word is in uppercase? Succinct though, my solution ended up like this:

import re

word = "sUpercalifragilisticexpialidocious"
def count_vowels(word):
    word = word.lower()
    letters = list(word)
    count = 0
    for letter in letters:
        if re.match("[aeiou]",letter):
            count += 1
    print count


code of conduct - report abuse