File system · 7 / 15 Exercise Medium

Count files by extension

Objective

The program runs inside a folder that already contains the files of the test case. With Path.rglob("*") you walk through the files of the folder and of all its subfolders. The extension is path.suffix.

Instructions

  • Count the files by their extension (in lowercase, with the dot, for example .txt).
  • Files without extension are counted as (none).
  • Show one line extension: n per extension, sorted alphabetically.

Example. With a.txt, b.TXT, src/main.py, notes/c.txt and Makefile it shows (none): 1, .py: 1 and .txt: 3.

Output
(none): 1
.py: 1
.txt: 3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise