Giacomo M Giacomo M - 6 months ago 31
Python Question

Python 2.7.10 how to iterate files creation with different names

I would like to create a different number of files with Python 2.7.10. The number of them is determined by the i index ( range(X) where X is already been defined) and the name should be like :file1,file2,file3,file4...filei. Here what I was writing:

list3 = range(X)
for i in list3:
# (here I want to add the creation process)

Thanks to everyone!!

list3 = range(x)
for i in list3:
    with open("File%i" % i, "w") as myfile:
        #do something