This commit is contained in:
2023-12-01 15:49:18 +01:00
parent 672820fffc
commit dd427b999b

View File

@@ -0,0 +1,32 @@
#!/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)