Code:
test = [1, 2, 3, 4, 2, 2, 3, 1, 4, 4, 4]
print(max(set(test), key = test.count))
Result:
4
In the above code, how does it work overall?
My understanding is, after the list test is converted to a set, all duplicate elements are lost. Then how does the max function find the value with the most occurances in the list?