1002. 写出这个数 (20) Python

numbers = input()
sum = 0
for number in numbers:
    sum = sum + int(number)
strsums = str(sum)
info = []
for strsum in strsums:
    if strsum == '1':
        info.append("yi")
    elif strsum == '2':
        info.append("er")
    elif strsum == '3':
        info.append("san")
    elif strsum == '4':
        info.append("si")
    elif strsum == '5':
        info.append("wu")
    elif strsum == '6':
        info.append("liu")
    elif strsum == '7':
        info.append("qi")
    elif strsum == '8':
        info.append("ba")
    elif strsum == '9':
        info.append("jiu")
    else:
        info.append("ling")
result = ''
i = 0
while i < len(info) - 1:
    result = result + info[i] + ' '
    i = i + 1
result = result + info[-1]
print(result)

你可能感兴趣的:(python)