Finding empty directories in Python June 4, 2023 by Tarik import os if not os.listdir(dir): os.rmdir(dir) LBYL style. for EAFP, see mouad’s answer.