Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Most Frequent by anikwon79
def most_frequent(data):
"""
determines the most frequently occurring string in the sequence.
"""
newDict = dict()
for i, elm in enumerate(data):
if elm not in newDict:
newDict[elm] = 0
newDict[elm] += 1
mostNumber = 0
mostChar = ''
for key in newDict:
if newDict[key] > mostNumber:
mostNumber = newDict[key]
mostChar = key
print(newDict , '------------>' , mostChar)
return mostChar
Oct. 19, 2017