I am trying to make a dictionary to keep account of what values from array 1 are present in array 2 in order to locate any missing values, and then print the dictionary.
I keep getting the following error:
KeyError: 1 at 'count[x] += 1'
I can't make sense of it. I am a beginner to data structures and I'd appreciate any help.
Here is what I have written:
def finder(arr1,arr2):
arr1.sort()
arr2.sort()
count = {}
for x in arr1:
if x in arr2:
count[x] += 1
print(count)