I created a series of *.txt file using the for loop. But now I want to write the file names in a list. But only the last file name is getting printed in the list and the before ones gets deleted.
for i in range(3):
i += 0
new_file = str(i) + ".txt"
file_list = []
file_list.append(new_file)
with open(new_file, "w") as outfile:
print("File created...")
print(file_list)
The output I am getting is ['2.txt']
I need the output to be ['0.txt', '1.txt', '2.txt']