I have list:
s = list(map(int, ['0', '0', '2', '1', '1', '0', '0', '0']))
I need to figure out how to take a nonzero number from the list that has more concurrence (in this example it is '1'). If concurrence of numbers is the same (e.g. ['0', '2', '2', '1', '1', '0', '0']) take first nonzero number in the list (in this example it is '2'). If the list consists of zeros than return zero.
It seems that
max(set(s), key=s.count)
can help but it has problems with zeros. For the example above it returns 0.