请问下这个python代码在pta提交部分正确如何修改?
以下为源码(python新手,请别介意,努力提升中):
# 数字转汉语拼音
def tran(num):
if num == 0:
str = 'ling'
return str
elif num == 1:
str = 'yi'
return str
elif num == 2:
str = 'er'
return str
elif num == 3:
str = 'san'
return str
elif num == 4:
str = 'si'
return str
elif num == 5:
str = 'wu'
return str
elif num == 6:
str = 'liu'
return str
elif num == 7:
str = 'qi'
return str
elif num == 8:
str = 'ba'
return str
elif num == 9:
str = 'jiu'
return str
n = input()
sum = 0 # 记录各数字之和
num = 0 # 读取 sum 每一位数字
for i in n:
sum = sum + int(i)
for j in str(sum):
num = int(j)
print(tran(num))