Listing 09-09: Check if a directory or file already exists

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 09\09.09 - Check if a directory or file already exists.py
# Description: Check if a directory or file already exists
##############################################################################

import os.path
if os.path.exists("z"):
    print("The z directory exists.")
else:
    print("The z directory doesn't exist.")
Click here to download the file