First line contains N. Second line contains list of N integers each separated by a space. I need to find the second largest number in list.
My code:
N = int(raw_input())
L = map(int, raw_input().split())
for i in L:
if i == max(L):
L.remove(i)
print L
print max(L)
If input is [2, 6, 9, 9, 5]
, this still prints maximum value: 9, as only one 9 is getting removed from the list.
So, how to remove all the 1st maximum values in the list?