有什么方法可以将列表中的元素分配给字典的键?

时间:2019-12-29 08:43:02

标签: python list dictionary

dic={'a':None,'b':None,'c':None,'d':None,'e':None,'f':None,'g':None,'h':None,'i':None,'j':None,'k':None,'l':None,'m':None,'n':None,'o':None,'p':None,'q':None,'r':None,'s':None,'t':None,'u':None,'v':None,'w':None,'x':None,'y':None,'z':None}
arr=list(map(int,input().rstrip().split()))
for i in arr:
    for j in dic.keys():
        dic[j]=i
        break
for values in dic.values():
    print(values)

是否可以将列表中的元素分配给字典的键?它仅将列表的第一个元素分配给字典的第一个键对。

0 个答案:

没有答案