Answers for "def most_frequent(given_list): max_count = -1 max_item = None count = {} for i in given_list: if i not in count: count[i] = 1 else: count[i] += 1 if count[i] > max_count: max_count = count[i] max_item = i return max_item"

0

def most_frequent(given_list): max_count = -1 max_item = None count = {} for i in given_list: if i not in count: count[i] = 1 else: count[i] += 1 if count[i] > max_count: max_count = count[i] max_item = i return max_item

def most_frequent(given_list):
    max_count = -1
    max_item = None
    count = {}
    for i in given_list:
        if i not in count:
            count[i] = 1
        else:
            count[i] += 1
        if count[i] > max_count:
            max_count = count[i]
            max_item = i
    return max_item
Posted by: Guest on August-13-2021

Code answers related to "def most_frequent(given_list): max_count = -1 max_item = None count = {} for i in given_list: if i not in count: count[i] = 1 else: count[i] += 1 if count[i] > max_count: max_count = count[i] max_item = i return max_item"

Browse Popular Code Answers by Language