I want to remove the list which contains the maximum number( In this list 16)
Code sample
Lst = [["D",16],["B",10],["A",13],["B",16]]
required output
Lst =[["B",10],["A",13]]
>Solution :
Lst = [["D",16],["B",10],["A",13],["B",16]]
max_elem = -float("inf")
for element in Lst:
if element[1] > max_elem:
max_elem = element[1]
for i in reversed(range(len(Lst))):
if Lst[i][1] == max_elem:
Lst.pop(i)
print(Lst)