I am trying to get the code to list all the directories in a folder, change directory into that folder and get the name of the current folder. The code I have so far is belo
You seem to be using Python as if it were the shell. Whenever I've needed to do something like what you're doing, I've used os.walk()
For example, as explained here: [x[0] for x in os.walk(directory)] should give you all of the subdirectories, recursively.
[x[0] for x in os.walk(directory)]