I'm super new to programming. I'm supposed to find the runner up score. My logic is sorting the list, deleting the maximum element(s) and printing the new maximum element.
Here's what I've tried:
enter code here
n = int(input())
arr = list(map(int , input().split()))
arr.sort()
a=arr
for i in range(len(a)-1):
if a[i]==max(arr):
del a[i]
else:
continue
print(arr)
When I give n=5 and list elements [2,3,5,6,6] then my output is [2,3,5,6]. The other 6 isn't getting removed. I suspect that del is messing with the indexing of the list. Please do tell me where I've gone wrong, thank you.