This is my code. It is everything I have in my programme:
from pathlib import Path
new_dir = Path.home() / "new_directory"
file_path = new_dir / "program2.py"
file_path.unlink(missing_ok=True)
The file program2.py does not exist; that is why I wanted to set the missing_ok parameter to True so that it would not raise a FileExistsError. But every time I run the code it gives me the following message:
file_path.unlink(missing_ok=True)
TypeError: unlink() got an unexpected keyword argument 'missing_ok'
Do I have an outdated version of python or have I made a mistake in the code, help would be much appreciated!