Answers for "python add array duplicate dictionary"

4

switching keys and values in a dictionary in python [duplicate]

my_dict = {2:3, 5:6, 8:9}

new_dict = {}
for k, v in my_dict.items():
    new_dict[v] = k
Posted by: Guest on February-16-2020
3

python convert two lists with duplicates to dictiona

dict_1={}

for key,value in zip(list_one,list_two):
    if key not in dict_1:
        dict_1[key]=[value]
    else:
        dict_1[key].append(value)

print(dict_1)
Posted by: Guest on November-10-2020

Code answers related to "python add array duplicate dictionary"

Python Answers by Framework

Browse Popular Code Answers by Language