os.listdir() vs os.mkdir()
os.listdir() and os.mkdir() are both Python OS Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. os.listdir(): Returns a list of all files and directories in the given path. Its syntax is os.listdir(path="."), and it returns list of filenames os.mkdir(): Creates a single directory. Raises FileExistsError if it already exists. Its syntax is os.mkdir(path, mode=0o777, *, dir_fd=None), and it returns none Example of os.listdir(): os.listdir(".") # ["file.py", "dir", ...]. Example of os.mkdir(): os.mkdir("new_folder"). Read the full references for os.listdir() and os.mkdir() to see parameters, edge cases, and example code side by side. Other OS Module APIs worth comparing: os.getcwd(), os.chdir(), os.makedirs(), os.remove(), os.rmdir(), os.removedirs(). Both belong to the OS Module category in the Python Reference documentation. Try both in the Python playground to see the behavioral difference live.