#!/usr/bin/env python3 import re lines = (x.strip() for x in open("input.txt")) total = 0 regex = re.compile("\d") for line in lines: first = regex.search(line)[0] last = regex.search(line[::-1])[0] total += int(first + last) print(total)