I am trying to use python to create an individual text file for every item in a list.
List = open('/home/user/Documents/TestList.txt').readlines()
List2 = [s + ' time' for s in List]
for item in List2 open('/home/user/Documents/%s.txt', 'w') % (item)
This code should generate a list from a target text file. A second list is generated using the strings from the first list with some appendage (in the case, adding ' time' to the end). My third line is where I'm running into problems. I want to create an individual text file for each item in my new list where the name of the text file is the string of that list item. Example: If my first list item was 'healthy time' and my second list item was 'food time', text files called "healthy time.txt" and "food time.txt" would be generated.
It appears i'm running into an issue with the open command, but I have searched extensively and found nothing regarding using open in the context of a list.