Among Us Voting System: HALP AGAIN
Smart0ne (725)


Let's say I have the following code:

votes = {"red":2,"yellow":1,"green":0,"cyan":2,"blue":1,"magenta":0}

It's a dictionary named "votes". Now I want a function that can return the key names of the values that have the maximum value. If this is unclear, the function should return

ejected = ["red","cyan"]

since "red" and "cyan" have the biggest values in the dictionary. Can someone help me implement this?

Thanks in advance!

You are viewing a single comment. View All

You might want to do this:

votes = {
    "red": 3,
    "yellow": 1,
    "green": 0,
    "cyan": 3,
    "blue": 1,
    "magenta": 0

def getKey(val):
    for k, v, in votes.items():
        if val == v:
            return k

new_list = []
for key, value in votes.items():

ejected = []
max_value = max(new_list)


it will only give you the color with the largest votes
it will only return one colors, not two

Smart0ne (725)

@SUHASTADIPARTH1 Thanks! :) My goal is to return all the ones with the highest value, but thanks for the code!

heyitsmarcus (342)

@SUHASTADIPARTH1 The objective is to return both colors, not just one.