On 11/11/2022 07:22, DFS wrote:

[(0,11), (1,1),  (2,1),
  (0,1) , (1,41), (2,2),
  (0,9) , (1,3),  (2,12)]

The set of values in elements[0] is {0,1,2}

I want the set of max values in elements[1]: {11,41,12}



def build_max_dict( tups):
    dict = {}
    for (a,b) in tups:
        if (a in dict):
            if (b>dict[a]):
                dict[a]=b
        else:
            dict[a]=b
    return(sorted(dict.values()))


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to