Python Practice › OS Module Programs › Program 32
Create a full path with os.makedirs()
Write a Python program to create every folder of a path with os.makedirs().
Output
True
Approach
exist_ok=Truemakes repeated runs safe.
Solution
import os os.makedirs("a/b/c/d", exist_ok=True)os.makedirs("a/b/c/d", exist_ok=True)print(os.path.isdir("a/b/c/d"))Output
True
Learn the concept
New to this topic? Read the lesson, then come back.