re: Daily Challenge #80 - Longest Vowel Change VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Hi, this is my first time sharing my code here, so please don't judge :) But I really like these little challenges, thank you! Here we go (python ...
 

Hi @heidrichj you could also use the class Counter from collections package :)

from typing import Union
from collections import Counter

def vowel(word: str) -> Union[int, None]:
    letters = ('a', 'e', 'i', 'o', 'u')
    letters_on_word = Counter(word)

    for letter, quantity in letters_on_word.most_common():
        if letter in letters:
            return quantity

Tip:

Always use tuple in a list that is "fixed" to ensure that this list will be immutable

code of conduct - report abuse