Answer:
You can't call a function unless you've already defined it. Move the def createDirs(): block up to the top of your file, below the imports.
Explanation:
Some languages allow you to use functions before defining them. For example, javascript calls this "hoisting". But Python is not one of those languages.
The CPU is the working principle