python-workout icon indicating copy to clipboard operation
python-workout copied to clipboard

e12b1_most_repeated_vowels.py gives IndexError if word has no vowels

Open godamockute opened this issue 3 years ago • 0 comments

My suggestion:

def most_repeating_vowel_count(word):
    vowels = 'aieouAIEOU'
    vowel_dict = Counter({letter: count for letter, count in Counter(word).items() if letter in vowels})
    if not vowel_dict:  # if there are no vowels in the word
        return 0
    else:
        return vowel_dict.most_common(1)[0][1]

godamockute avatar Apr 26 '22 08:04 godamockute