I am trying to add new key pair value to to a dictionary:
What my code outputs at the moment is:
dict_items([((2, 2), 2)])
What I actually want:
{(0, 0): 0}, {(0, 1): 2}, {(0, 2): 3}, {(1, 0): 1}, {(1, 1): 1}, {(1, 2): 2}, {(2, 0): 5}, {(2, 1): 3}, {(2, 2): 2}
Can anyone explain how to update my dictionary with the new key value pairs? I tried using update function call but got the following error:
TypeError: unhashable type: 'set'
Any help is highly appreciated!
    distanceList = []
    trainingset = [5, 6, 10]
    testset = [5,7,8]
    for i in trainingset:
        for j in testset:
            distance = abs(i-j)
            values = dict()
            values[trainingset.index(i),testset.index(j)] = distance
            # values.update({{trainingset.index(i),testset.index(j)}:distace})
            distanceList.append(distance)
    print(distanceList)
    print(values.items())
 
    