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 jahmee
def most_frequent(data):
data.sort()
licznik=1
max_licznik=1
poszukiwany = data[0]
x = len(data)
for i in range(1,x):
if data[i]==data[i-1]:
licznik+=1
else:
if max_licznik max_licznik:
max_licznik = licznik
poszukiwany = data[x - 1]
licznik = 1
return poszukiwany
"""
determines the most frequently occurring string in the sequence.
"""
# your code here
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert most_frequent([
'a', 'b', 'c',
'a', 'b',
'a'
]) == 'a'
assert most_frequent(['a', 'a', 'bi', 'bi', 'bi']) == 'bi'
print('Done')
Oct. 23, 2017