The os module also enables deleting files using the remove() function. Any file that is passed as an argument to the function is deleted. In the File I/O section, we discussed reading from files using the text file, read_file.txt. Let's delete the file by passing it as an argument to the remove() function:
os.remove('/home/pi/Desktop/code_samples/read_file.txt')