To write a python program for getting the word count from the contents of a file using command line arguments.
PC Anaconda - Python 3.7
Recieve the input.
Read through the lines.
Count the words.
Write the code.
Execute the code.
Recieve the output.
Developed by: kavya.k
Reference number: 22008613
import sys
count={ }
with open (sys.argv[1],'r') as f:
for line in f:
for word in line.split():
if word not in count:
count[word]=1
else:
count[word]+=1
print(count)
f.close()
Thus the program is written to find the word count from the contents of a file using command line arguments.