
Let us create an example to list all the directories present in the current working directory that is The above command will list all directories in the current working directory, and another syntax will take the path as an argument and list all the directories in that path. The syntax to list python directories is as below: In python, directories at any given location can be listed using the OS module, which has many functions and to list is listdir() function. In the above output, we can able to see the new directories ‘repository’ and ‘sdk’, which we created in the above example.

Now we will see the output of directories available in the current working directory after the creation of the above directories in the example and output as below:
