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
Initially make count = 0
Open the content file using command line arguments.
By using for loop name the function as "line"
Split the line using .split
Count the length of the word and print it
#Developed by : VIGNESH KUMARAN N.S
#ROLL NO : 22008928
import sys
count=0
with open(sys.argv[1],'r') as f:
for line in f:
word=line.split()
count+=len(word)
print("Word Count in File=",count)
Thus the program is written to find the word count from the contents of a file using command line arguments.