How to make a dictionary from 2 lists (1 list being the keys and the other values)
The first example I tried to use list comprehensions to create a dictionary from 2 lists, but it’s giving me an error
key = IN[0]
values = IN[1]
result = {key[i] : values[i] for i in range(len(key))}
OUT = result
For the second example, I used defaultdict to try to create a list with repeated keys, but again it returns an error.
key = IN[0]
values = IN[1]
result = defaultdict(list)
for i, j in zip(key, values):
result[i].append(j)
OUT = result
Both of these examples worked in the online python compiler