import sys filename = '%s' %(sys.argv[1]) with open(filename, newline='') as f: content = f.readlines() count = 0 for line in content: if line.startswith('####'): count = count + 1 print(count)