Merging two lists into dictionary while keeping duplicate data in python

后端 未结 8 2083
北海茫月
北海茫月 2021-01-17 09:09

Hi, I want to merge two lists into one dictionary. Suppose I have two lists such as below

list_one = [\'a\', \'a\', \'c\', \'d\']

list_two = [1,2,3,4]

8条回答
  •  情歌与酒
    2021-01-17 09:46

    A defining characteristic of dicts is that each key is unique. Thus, you can't have two 'a' keys. Otherwise, what would my_dict['a'] return?

提交回复
热议问题