#!/usr/bin/env python3 # -*- coding: utf-8 -*- def numword2int(text): text = text.replace("one", "1") text = text.replace("two", "2") text = text.replace("three", "3") text = text.replace("four", "4") text = text.replace("five", "5") text = text.replace("six", "6") text = text.replace("seven", "7") text = text.replace("eight", "8") text = text.replace("nine", "9") # text = text.replace("zero", "0") return text input_file = open("input", "r") summe = 0 for line in input_file: v1, v2 = "", "" line = numword2int(line.strip()) for b in line: if b.isdigit() and v1 == "": v1 = b if b.isdigit() and v1 != "": v2 = b print(v1+v2, line) summe += int(v1+v2) input_file.close() print(summe)