Remove an empty folder

EasyOS Module Programs · 8 of 49

Write a Python program to remove an empty directory with os.rmdir().

Advertisement
Output
False

Approach

  1. rmdir only removes empty folders.

Solution

Python
import os os.makedirs("empty_dir", exist_ok=True)os.rmdir("empty_dir")print(os.path.exists("empty_dir"))
Output
False

Learn the concept

New to this topic? Read the lesson, then come back.

More os module programs

← All 49 OS Module Programs

Leave a Comment