import os if os.path.isfile('/Users/test/new_file.txt'): os.remove('/Users/test/new_file.txt') print("success") else: print("File doesn't exists!")