Objective
The program runs inside a folder that already contains the files of the test case. mkdir(exist_ok=True) creates a folder and path.rename(target) moves (or renames) a file to another path.
Instructions
- Move each file of the current folder (without touching subfolders) to a folder named as its extension, without the dot and in lowercase (for example
foto.JPGgoes tojpg/foto.JPG). - Files without extension stay where they are.
- Show
Files moved: nwith the number of files moved.
Example. With notes.txt, photo.JPG, data.csv, README and b.txt you end up with txt/notes.txt, txt/b.txt, jpg/photo.JPG, csv/data.csv and README, and it shows Files moved: 4.
Files moved: 4
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise