How to Get a List of All Files in a Directory With Python Quiz

Interactive Quiz ⋅ 10 Questions
By Joseph Peart

In this quiz, you’ll test your understanding of How to Get a List of All Files in a Directory With Python.

By working through this quiz, you’ll revisit how .iterdir() hands you the contents of a single directory, how glob patterns let .glob() and .rglob() filter results by name, and how .rglob() walks an entire directory tree.

You’ll also check your understanding of filtering on attributes with comprehensions and filter(), and of skipping junk directories instead of listing every file inside them.

The quiz contains 10 questions and there is no time limit. You’ll get 1 point for each correct answer. At the end of the quiz, you’ll receive a total score. The maximum score is 100%. Good luck!

Related Resources

How to Get a List of All Files in a Directory With Python

Course

Listing All Files in a Directory With Python

In this video course, you'll be examining a couple of methods to get a list of files and folders in a directory with Python. You'll also use both methods to recursively list directory contents. Finally, you'll examine a situation that pits one method against the other.

intermediate stdlib

How to Get a List of All Files in a Directory With Python

Tutorial

How to Get a List of All Files in a Directory With Python

In this tutorial, you'll be examining a couple of methods to get a list of files and folders in a directory with Python. You'll also use both methods to recursively list directory contents. Finally, you'll examine a situation that pits one method against the other.

intermediate stdlib