【发布时间】:2019-03-15 04:32:53
【问题描述】:
代码:
score={'a':1,'b':2,'c':3,'d':4,'e':5} #value of the alphabet
或
a=1
b=2
c=3
d=4
e=5
word=input('Enter a word:')
word_list=list(word)
for x in word:
print(x)
如果我输入bad
输出:
b
a
d
问题:我怎样才能把字母表的值放在它旁边(在输出中),像这样:
b 2
a 1
d 4
【问题讨论】:
-
那么你有一个字典还是一堆变量?选择一个并提出一个明确的问题。
-
还有1个问题,如果我想找到值的总和,我可以使用sum()吗?