Reputation: 39
lets say I have the following dictionary
dict1= {"a":[1,2,3],"b":[2,3,4]}
how would I make it so the output is:
[2,3]
where the values match in a dictionary.
Upvotes: 0
Views: 64
Reputation: 114
you can refer to my code bellow:
arr1 = d['a']
arr2 = d['b']
arrResult = []
for i in arr1:
if i in arr2:
arrResult.append(i)
print(arrResult)
and here is the result: [2, 3]
More advanced you can use:
x = set.intersection(*map(set, d.values()))
print(x)
Upvotes: 2