Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: count characters

  • Write a script called count_characters.py that given a long text will count how many times each character appears.
  • Change the code so it will be able to count characters in a file.
text = """
This is a very long text.
OK, maybe it is not that long after all.
"""