import random


def max_vote(votes):
    """Manual bilding of counts and selection randomly the max vote (count) in the case of a tie."""
    counts = {}
    for vote in votes:
        if vote in counts.keys():
            counts[vote] += 1
        else:
            counts[vote] = 1
    # print(counts)
    # Building the list of max values
    most_frequent = []; maxCount = max(counts.values()) # In the case of a tie, there will be a few keys corresponding to the max
    for key, val in counts.items():
        if val == maxCount:
            most_frequent.append(key)
    return random.choice(most_frequent)