测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔.当A和B同时为0时输入结束,相应的结果不要输出.
对每个测试用例输出1行,即A+B的值.
one + two = three four + five six = zero seven + eight nine = zero + zero =
3 90 96
while True: try: string = input().lower() if string == "zero + zero =": break numEnglish = ['zero','one','two','three','four','five','six','seven','eight','nine'] string = string.split("+") left = string[0].strip().split() right = string[1].strip('=').split() leftNum = '0' rightNum = '0' for i in left: leftNum += str(numEnglish.index(i)) for i in right: rightNum += str(numEnglish.index(i)) print(int(leftNum)+int(rightNum)) except Exception: break