1def count_letters(text):
2 result = {}
3 # Go through each letter in the text
4 for letter in text:
5 # Check if the letter needs to be counted or not
6 if letter not in result:
7 result[letter.lower()] = 1
8 # Add or increment the value in the dictionary
9 else:
10 result[letter.lower()] += 1
11 return result
12
13 print(count_letters("AaBbCc"))
14 # Should be {'a': 2, 'b': 2, 'c': 2}
15
16 print(count_letters("Math is fun! 2+2=4"))
17 # Should be {'m': 1, 'a': 1, 't': 1, 'h': 1, 'i': 1, 's': 1, 'f': 1, 'u': 1, 'n': 1}
18
19 print(count_letters("This is a sentence."))
20 # Should be {'t': 2, 'h': 1, 'i': 2, 's': 3, 'a': 1, 'e': 3, 'n': 2, 'c': 1}
21