Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

terminal exercises

Views: 2497
1
#! /usr/bin/python3
2
3
import sys
4
print("This is the name of the script: ", sys.argv[0])
5
print("Number of arguments: ", len(sys.argv))
6
print("The arguments are: " , str(sys.argv))
7
8
for filename in sys.argv[1:]:
9
file_content = open(filename,"r").read()
10
wordcount = len(file_content.split())
11
print("{} wordcount = {}".format(filename,wordcount))
12
13