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
import sys
fp=open(sys.argv[-1],'r')
count=0
for line in fp:
words=line.split()
count+=len(words)
print("Number of words in a file",count)
Thus the program is written to find the word count from the contents of a file using command line arguments.