Open a file for each element of an array in Python -


i new this. trying create file each element in array. example if , array has 3 elements ["a","b","c"], want able create 3 files called a.txt, b.txt, , c.txt.

thanks

if want create , name file each element in list, have loop through list this:

for in ["a","b","c"]:     open(i +".txt", "w+") f:         f.write("hello") 

this create 3 files a.txt, b.txt , c.txt string "hello" in each file.


Comments