I have a python list ['a','b','c']
that's generated inside a for loop. I would like to write each element of the list to a new file.
I have tried:
counter = 0
for i in python_list:
outfile = open('/outdirectory/%s.txt') % str(counter)
outfile.write(i)
outfile.close()
counter += 1
I get an error:
IOError: [Erno 2] No suchfile or directory.
How can I programmatically create and write files in a for loop?