import sys class line: def __init__(self, tempinp, tempout): self.inp = [] self.out = [] self.inp = tempinp.split(' ') self.out = tempout.split(' ') def countout(self): self.count = 0 for digit in self.out: if 2 <= len(digit) <= 4 or len(digit) == 7: self.count += 1 return self.count terminal = [] count = 0 with open(sys.argv[1], 'r') as f: for i in f.readlines(): tempin = i.strip() inp, out = tempin.split(' | ') terminal.append(line(inp, out)) for lin in terminal: count += lin.countout() print(count)