OneCompiler

countVowels

133
def count_vowels(text):
    vowels = {"a", "e", "o", "u", "i"}
    memory = {}
    count = 0
    for char in text:
        curr = char.lower()
        if curr in vowels:
            memory[curr] = memory.get(curr, 0) + 1
            # OR:
            # if curr in memory:
            #     memory[curr] += 1
            # else:
            #     memory[curr] += 1
    for key in memory:
        count += memory[key]
    return count


text = input("Enter the text to count vowels here:")
print("Count: ", count_vowels(text))