I want to take multiple file as input from command-line like
#python script.py file1.txt file2.txt file3.txt .... file_N.txt
following program can take only one file as input
python script.py file1.txt
But I want to take multiple file as input.
import sys
with open(sys.argv[1], 'r') as file:
wordcount = file.read()
words= wordcount.split()
#print(words)
count = {}
for word in words:
if word in count:
count[word]=count[word] + 1
else:
count[word] = 1
print(count)