Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Some tricks with max() function. solution in Clear category for The Most Frequent by ArchTauruS
"""Some tricks with max() function.
1, max() can sort not only int, float, str, but also touple, list, etc.
2, so use max() can easily find the max of [(count1, item1), (count2, item2), ...] for count.
"""
def most_frequent(data):
return max((data.count(c), c) for c in set(data))[1]
Nov. 9, 2018
Comments: