I have multiple files, let's say data{1..10}.txt in folder data/
I need to read these files into python environment for further use, example code i have in mind is:
chr_list = []
x = 0
for item in range(10):
datafile="data/data"+str(i+1)+".txt"
chr_list[x] = open(datafile, "r")
x += 1
The expected outcome would be
print(chr_list[0])
#prints out content of file data/data1.txt
This code doesn't work even after correcting all possible errors. Thus, i would like to see some examples on how to reach my desired outcome.
chr_list.append(open(datafile, "r").read())appendto it. I updated my comment.