I made this Python code to store the key and values in the dictionary
num = [1,2,3,2,1,2,2,4,5,4,4,4]
dict1 = {}
for val in num:
if val in dict1:
dict1[val] = dict1[val] + 1
else:
dict1[val] = 1;
print(max(dict1,key=dict1.get))
Max function is returning the first value it encounters. Please advise what to do in case of a tie.
Thanks!
max
only returns one value