File system · 10 / 15 Exercise Medium

Search with patterns

Objective

The program runs inside a folder that already contains the files of the test case. Path.glob(pattern) searches for files and folders whose name matches a pattern: * any sequence, ? one character and ** any number of subfolders.

Instructions

  • Read a pattern (for example *.txt or **/*.py).
  • Show, sorted and one per line, the relative paths (with / as separator) that match the pattern.

Example. With the pattern *.txt and the files a.txt, b.py and docs/c.txt only a.txt is shown: the * does not go into subfolders.

Input
*.txt
Output
a.txt

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

Start exercise