I'm trying to count how many times each letter appears in a piece of text.
def count_letters(text):
result = {}
for letter in text:
if letter not in result:
result[letter]= 0
result[letter] += 1
return result
count_letters("aaad g a")
When I type this code however, it's only showing 1 as the values for each key. I was expecting 4 for a, 1 for d, etc