Python : How to count number of times each character appears in a string

Recently, I needed to count the number of times the characters appear inside a specific sentence. As I was learning Python at that time, this looked like a perfect opportunity to use it to solve a real problem and it is the focus of this article. First, we will use a dictionary to accomplish this task and in the second solution, we will make use of the collections module.