Second largest · 두 번째로 큰 값
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
This one builds on a lesson you haven't finished yet. Do that lesson first: · 이 과제는 아직 완료하지 않은 수업에 기반합니다. 먼저 해당 수업을 완료하세요:
Python Basics · Functions →
Second largest
Return the second-biggest distinct value. Duplicates of the maximum don't count, so [5, 5, 4] gives 4, not 5.
One clean route: drop duplicates with set(...), sort the result, and take the value one in from the end with [-2].
Write second_largest(xs) that returns the second-largest distinct value in xs. You may assume there are at least two distinct values. · second_largest(xs)를 작성하여 xs에서 두 번째로 큰 상이한(distinct) 값을 반환하십시오. 최소 두 개의 상이한 값이 있다고 가정할 수 있습니다.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.