import os
import glob
# Get a list of all the file paths that ends with .txt from in specified directory
file_list = glob.glob('/home/varung/Documents/python/logs/*.log')
# Iterate over the list of filepaths & remove each file.
for file_path in file_list:
try:
os.remove(file_path)
except:
print("Error while deleting file : ", file_path)