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 numpy as np
Enter the input value
write a python program for getting the word count from the contents of a file using command line arguments.
Run the program
give the input
end the program.
'''
# developed by:HEMA LOKITHA P
# reg no: 23007550
'''
import sys
count= 0
with open(sys.argv[1],'r') as file:
for line in file:
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.