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 digits

23 345 12345
67 189 23 17
  1. Given the file examples/files/numbers.txt (or a similar file), create a file called count_digits_in_file.py that will count how many times each digit appears? The output will look like this. Just different values.
  2. Save the results in a file called report.txt.
0 0
1 3
2 3
3 4
4 2
5 2
6 1
7 2
8 1
9 1