Python coding lesson

tristan wheeler

Honorable
Feb 5, 2014
48
0
10,530
Hi everyone. I'm stuck in a python coding lesson. I need to "use the os module and an if statement to determine if a directory exists and create a directory called... Also I have to use os.path.isdir
 
Solution
import os

os.path.isdir (your directory here) will return a true/false statement.

To create the directory if one does not exist:
if not os.path.isdir (directory here):
os.makedirs(new path here)