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
Create a text file in a specific loaction of interest.
On the same location as the text file, create a python program file.
In python Program, import sys and open a text file with argument "sys.argv[1]"
using read() and split(), split the lines in the file into a sequence of words.
using len() count the number of words in the text file.
In command prompt, initiate python followed by program name and text file name to get the output.
#Developed By: Abishai K C
#Regiser NUmber: 23001564
import sys
f = open(sys.argv[1],"r")
data = f.read()
lst = data.split()
print(len(lst))
Thus the program is written to find the word count from the contents of a file using command line arguments.