I'm trying to iterate all elements in map(dictionary). But I'm getting this error. Why does it say dict as list? And how do we resolve this problem?
'list' object has no attribute 'items' on line 13 in main.py
def thirdfarthestdistance(arr,x):
map = {}
for elem in arr:
# Storing {(5, -3), (distance, element)}
map[abs(elem-x)] = elem
map = sorted(map)
count = 0
for key, value in map.items: # I tried map.items() too but didn't work.
print(value)
# if count == 2:
# return elem
count = count + 1
print(thirdfarthestdistance([-3, -2, -1, 4, 7], 2))