- I have a list that I am using for a for-loop.
- Each item in the list has an action carried out, but I want to write a file for what has happened.
- How can I use the variable in the for loop to create specific file names for each item in the list?
mylist = ['hello', 'there', 'world']
for i in mylist:
outputfile = open('%i.csv', 'a')
print('hello there moon', file=outputfile)
- Am I on the right track using
%i
to represent individual items in the list?