Find the Runner-Up Score!

  • + 0 comments

    This is what I came up with.

    if __name__ == '__main__':
        n = int(input())
        arr = map(int, input().split())
        
        lst_scores = sorted(list(arr), reverse=True)
    
        for i in range(1, n): # we can skip the position 0 as that is the max since list is sorted in desc order
            if lst_scores[i] < lst_scores[0]: # lst_scores[0] is max
                v_runner_up = lst_scores[i] # if the above condition is true then we set the v_runner_up to the 2nd highest
                break
        print(v_runner_up)