词典
,它以
并将其拆分为单个
串
所以
词典
我知道有一种方法可以简化代码并使其大大缩小,但我不知道如何实现。
也许我应该用
在里面
变量
len()
是的,我是编程新手。
提前感谢!
decoder = {
"96": "0",
"97": "1",
"98": "2",
"99": "3",
"100": "4",
"101": "5",
"102": "6",
"103": "7",
"104": "8",
"105": "9",
}
test = list(str(num) for num in
input("Enter the list items
separated by space:
").strip().split()).
length = len(test)
if length == 1:
a, = test
print(decoder[a])
elif length == 2:
a, b = test
print(decoder[a])
print(decoder[b])
elif length == 3:
a, b, c = test
print(decoder[a])
print(decoder[b])
print(decoder[c])
elif length == 4:
a, b, c, d = test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
elif length == 5:
a, b, c, d, e = test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
print(decoder[e])
elif length == 6:
a, b, c, d, e, f = test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
print(decoder[e])
print(decoder[f])
elif length == 7:
a, b, c, d, e, f, g = test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
print(decoder[e])
print(decoder[f])
print(decoder[g])
elif length == 8:
a, b, c, d, e, f, g, h = test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
print(decoder[e])
print(decoder[f])
print(decoder[g])
print(decoder[h])
elif length == 9:
a, b, c, d, e, f, g, h, i =
test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
print(decoder[e])
print(decoder[f])
print(decoder[g])
print(decoder[h])
print(decoder[i])
elif length == 10:
a, b, c, d, e, f, g, h, i, j =
test
print(decoder[a])
print(decoder[b])
print(decoder[c])
print(decoder[d])
print(decoder[e])
print(decoder[f])
print(decoder[g])
print(decoder[h])
print(decoder[i])
print(decoder[j])