import re import sys def isPostalCode(s): pattern = re.compile(r'^([0-9]{2})-([0-9]{3})$') match = re.match(pattern, s) if match: return match.group(1) else: return '' inFile = sys.argv[1] outFile = sys.argv[2] # inFile = 'test.in' # outFile = 'test.out' with open(inFile, 'r', encoding='utf-8') as inputFile, open(outFile, 'w', encoding='utf-8') as outputFile: for line in inputFile: line = line.strip() # result = "yes" if is_divisible_by_25(line) else "" outputFile.write(isPostalCode(line)+'\n')