I am trying to find the second minimum value in a nested list, where every sublist contains a name and a float value.
I need help with comparing the associated float values if there are any duplicate values.
if __name__ == '__main__':
n = int(input())
list = []
for _ in range(n):
name = input()
score = float(input())
list.append([name,score])
listsort = sorted(list,key = lambda x:x[1])
newlist = listsort[1:2]
#if listsort[]
newlist.sort()
print(newlist)
it works fine without duplicate values.
Input :
5
Harry
37.21
Berry
37.21
Tina
37.2
Akriti
41
Harsh
39
Output : [['Berry', 37.21] ['Harry', 37.21]]