I want to use the following code inside a function on 50 files in the same directory.
with open(files) as f:
my_list = [int(i) for line in f for i in line.split()]
I tried
with open(file1) as a, open(file2) as b, ... open(file50) as c:
list1 = [int(i) for line in a for i in line.split()]
list2 = [int(i) for line in b for i in line.split()]
...
list50 = [int(i) for line in c for i in line.split()]
my_list = list1 + list2 + ... list50
And thus combining the contents of 50 files into the same array. But that is way too long and complicated and it also doesn't work. I know there is a much easier way to do this, I just don't know how to do that yet. Any help is much appreciated.