
Untitled
By: a guest on
Dec 16th, 2011 | syntax:
Python | size: 0.32 KB | hits: 46 | expires: Never
def majority(A):
min = len(A)/2.0
counts = {}
for x in A:
if x in counts:
counts[x] += 1
else:
counts[x] = 1
a = max(counts.iteritems(), key = lambda x: x[1])
if a[1] > min:
print "The winner is:", a[0]
else:
print "There is no winner"