Using the os module's os.path.exists(directory), you can check if a directory exists or not.
example
import os
if not os.path.exists('my_folder'):
print("Given path doesn't exist")
else:
print("Given path exists")If you run this and folder is already there, you'll get the message −
"Given path exists"