
def votes_minimum(dic, minimum):
    for candidate in dic:
        if dic[candidate] <= minimum:
            return False
    return True


def can_most_voted(dic):
    winner = ''
    votes_winner = 0
    for candidate in dic:
        if dic[candidate] > votes_winner:
            winner = candidate
            votes_winner = dic[candidate]
    return winner


def votes_income(dvotes, dinc):
    unknown = []
    for candidate in dvotes:
        if candidate not in dinc:
            unknown.append(candidate)
    unknown.sort()
    return unknown


def wealthy_1(dvotes, dinc):
    # we built a list of tuples (income, person) of all people 
    lwealthy = []
    for person in dinc:
        lwealthy.append((dinc[person], person))
    # we sort the list starting with the higher income
    lwealthy.sort(reverse=True)
    # we keep the first 10
    lwealthy = lwealthy[:10]
    # we built the list of names from lwealthy: only names,
    # and  add '*' to the candidates 
    lret = []
    for income, person in lwealthy:
        if person in dvotes:
            person = person + '*'
        lret.append(person)
    return lret

# using dictionary methods and key parameter 
def wealthy_2(dvotes, dinc):
    lwealthy = list(dinc.items())
    lwealthy.sort(reverse=True, key = lambda x: (x[1]))
    lwealthy = lwealthy[:10]
    lret = []
    for person, income in lwealthy:
        if person in dvotes:
            person = person + '*'
        lret.append(person)
    return lret

# your choice
#wealthy = wealthy_1
wealthy = wealthy_2
