Below is a module count_empty.py that counts the number of empty strings in the given file, starting from the given line index.
import sys
args = sys.argv
if len(args) == 3:
file_name = args[1]
start = int(args[2])
with open(file_name) as inp:
counter = 0
for i, line in enumerate(inp):
if i < start:
continue
if not line.strip():
counter += 1
print(counter)
else:
print("The number of passed arguments is incorrect. ")
How would you run it from the command line? Let's say you want to check the file test.txt that is in the same directory as the script, and you want to start from the line with index 101.
Tip: You don't need to look at the code in detail, you just need to understand what arguments the script takes.