I am working with this list of files in a local directory:
docs = ['5d7d3c905deeb7978034cb40.txt','5d7d3c905deeb7978034cb40.txt','5d7d26ae5deeb7978034cab3.txt',
'5d7d268e5deeb7978034cab2.txt','5dac3ad15deeb749fcbbfeab.txt']
If I do this:
for doc in docs:
for txt in open(doc):
I manage to open and read the texts all together. But I want to get each one of them into a distinct variable.
My best solution, for now, is this one:
abstracts = []
for i in range(len(docs)):
for doc in docs:
for txt in open(doc):
txs = [txt] #each text
if txs not in abstracts:
abstracts.append(txs)
I can reach the txs I want by the use of indexes, but I am sure there must be a better way to do this.