I have produced a list of lists in Python of the form e.g.
track_list = [[3,1],[3,2],[3,3],[5,4],[5,8],[6,6],[8,1],[8,90]]
I would like to consider each given value in the first position and then select the lowest value in the second position. For the above, I would ideally like to get back the following:
[[3,1],[5,4],[6,6],[8,1]]
My attempted code is:
def mM(L):
x,y = zip(*L)
return (max(y))
for l in track_list:
first_entry=l[0]
for m in track_list:
while m[0] == first_entry:
second_entry = mM(track_list)
Is there any easy way to do this? I've been playing around with loops but have no idea how to focus on groups of the first element and am not really getting anywhere.
Any help would be most appreciated.
Thanks