There is some kind of folder and you need to know the names of its subfolders. For example:

We have this situation

test folder1 subfolder file1.txt folder2 file2.png 

The output should be:

[folder1, folder2]

Tried through os.walk, maybe I'm stupid, but how to do it?

    1 answer 1

    Use:

     dirs = next(os.walk('.'))[1] print(dirs)