I have two defaultdicts
and essentially I want to see if the values on both dictionaries match up for the same corresponding keys. For example: {1,4}
{1,4}
. So it looks for matching keys which is 1
and then checks to see if their value match up 4
which it does.
So in my case I have:
keyOne = [30, 30, 60, 70, 90]
valueOne = [3, 4, 6, 7, 0]
KeyTwo = [30, 30, 60, 70, 90]
valueTwo = [4, 5, 6, -10, 9]
I create two defaultdicts
as such:
one = defaultdict(list)
for k, v in zip(keyOne, valueOne):
one[k].append(v)
two = defaultdict(list)
for k, v in zip(keyTwo, valueTwo):
two[k].append(v)
I then want to add the entries where the keys match but the values don't - so I write this, but it doesn't work:
three = defaultdict(list)
for k,v in one.items():
for key in k:
if key in two.items():
if (value != v):
three[k].append(value)
I am not sure where I am going wrong and it would mean a lot if someone could help me fix it. I'm new to programming and really want to learn