Creating a dictionary from 2 lists with duplicate keys

前端 未结 2 1941
醉梦人生
醉梦人生 2020-12-18 14:12

Though I have seen versions of my issue whereby a dictionary was created from two lists (one list with the keys, and the other with the corresponding values), I want to crea

2条回答
  •  眼角桃花
    2020-12-18 14:58

    Keys need to be unique. 
    You Have keys = [18, 34, 30, 30, 18]
    Repeated keys 18 and 30 can not be used twice.
    Try your script with unique keys and it works fine.
    Keys read right to left. Notice you get the first key 18 
    and the first key 30, but the second of each key is passed over 
    

提交回复
热议问题