Project: Count the letters

Write a function called count_letters that takes a string and returns a dictionary showing how many times each letter appears in it. The string can contain characters that are not letters, and it can be empty. Count only letters, and count upper-case and lower-case as the same letter. The keys of the dictionary should be upper-case letters.

For example, given this string:

"AaBb"

the dictionary should hold these pairs:

{'A': 2, 'B': 2}

We have not covered the built-in isalpha(), so do not use it.

Save the file as count_letters.py.

Show a solution

Try the project on your own first. This is one working solution, followed by its tests. Press Run to run the tests. Read them to see what thorough testing looks like, then change the solution and run again to watch a test fail.

Projects run on your own computer, so you tell us when you are done.