Second-highest score

Write code · Medium · §3.1 Finding ranks

Complete the function solution, which returns the second-highest score among the distinct scores in the list scores.

If the highest score appears several times, it is counted only once. If there is only one distinct score, return -1.

Function

solution(scores)

Constraints

Examples

scoresresult
[90, 95, 95, 80]90
[70, 70]-1

Starter code

def solution(scores):
    answer = -1
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.