A quick solution in Python
The above code will delete a file in Python, it will not however delete a directory, or a directory containing files. For this we will need to explore a bit more..
Check file exists before deleting
First check if the file exists before deleting it:
Delete a directory/folder
Sometimes you may want to delete an entire folder as well:
What options are available?
Using Pathlib as an alternative
As of Python 3.4+, you can also use
pathlib as follows:
rmdir is also available to remove a blank directory: