We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
There's a small bug that could occur if all the entries are the same for n. I.e. if n = 2, and the list contains [1, 1] for scores, it will not evaluate. You'll need to add something along these lines in order to get around those cases; here's what I came up with.
i = int(input())
lis = list(map(int,input().split())) [:i]
z = max(lis)
if lis.count(lis[0]) == len(lis):
print(max(lis))
else:
while max(lis) == z:
lis.remove(max(lis))
print(max(lis))
Find the Runner-Up Score!
You are viewing a single comment's thread. Return to all comments →
There's a small bug that could occur if all the entries are the same for n. I.e. if n = 2, and the list contains [1, 1] for scores, it will not evaluate. You'll need to add something along these lines in order to get around those cases; here's what I came up with.
i = int(input()) lis = list(map(int,input().split())) [:i] z = max(lis) if lis.count(lis[0]) == len(lis): print(max(lis)) else: while max(lis) == z: lis.remove(max(lis)) print(max(lis))