Exercise: Find Text Files With Glob
Bartosz Zaczyński RP Team on June 20, 2026
@bart.jutte, the empty list ([]) is actually the useful clue. Path(directory).glob("*") doesn’t raise when the directory doesn’t exist, it just yields nothing, so an empty list even with a plain * almost always means glob is searching a different folder than you expect rather than a pattern issue.
The usual cause is a relative path resolving against the wrong working directory. IDLE and PyCharm often start with a current directory that isn’t where your files are, so something like "texts" ends up pointing at an empty (or missing) location. Quick check:
from pathlib import Path
directory = Path("your/path")
print(directory.resolve(), directory.exists())
print(list(directory.iterdir()))
If .exists() is False or .iterdir() is empty, point directory at the absolute path where the .txt files actually live (for example Path.home() / "some_folder").
A couple of side notes: .glob("*.txt") only looks one level deep, so for files in subfolders use .rglob("*.txt"). And the exercise platform passes in a directory that already contains test files, which is why your solution validates there even when a local run finds nothing.
The PyCharm “didn’t run at all” part sounds like a local environment or antivirus thing rather than your code. Running from a terminal with python your_script.py (or staying in IDLE) should unblock you, and if you can paste the exact error, the rest of the team and I are happy to take a look.
Become a Member to join the conversation.

bart.jutte on June 13, 2026
Usually, I run the code of exercises on my local machine to see if they work. This one, I wasn’t able to get working for some reason. I normally use PyCharm for this, but that didn’t run at all (some security thing?). IDLE resulted in empty
[]results, even after modifying the answer to include subfolders or just any file. Puzzling.