File system · 11 / 15 Exercise Easy

Name, extension and folder

Objective

pathlib does not need the file to exist: paths are objects that can be analyzed. PurePosixPath works only with the text of the path, without touching the disk.

Instructions

  • Read a path using / as the separator.
  • Show four lines: Name, Stem (without the extension), Suffix (with the dot, or empty) and Folder (the path of the folder that contains it).

Example. With /home/ana/docs/informe.txt it shows Name: informe.txt, Stem: informe, Suffix: .txt and Folder: /home/ana/docs.

Input
/home/ana/docs/informe.txt
Output
Name: informe.txt
Stem: informe
Suffix: .txt
Folder: /home/ana/docs

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

Start exercise