python-workout
python-workout copied to clipboard
e12b1_most_repeated_vowels.py gives IndexError if word has no vowels
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]