files and i/o — moving data in and out8 / 9
pathlib — the file api ai should reach for first
Write a function list_text_files(folder) that returns a list of the
names (not full paths) of all .txt files directly inside folder,
in sorted order.
Use Path.glob("*.txt") to find them. Use .name to get just the
filename from each Path. Wrap the result in sorted(...).
The starter creates three files in /tmp/notes/. Calling the function
should produce:
['alpha.txt', 'beta.txt']
(The .md file is filtered out by the glob.)
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _