easyUnit 6 · Lists & Tuples
P16. Second Largest
Lists & Tuples
Read a list of integers and print the largest value and the second largest distinct value. If all values are the same, there is no second largest; print None.
Input Format
- Line 1: integers separated by spaces
Output Format
- Line 1:
Largest: <value> - Line 2:
Second largest: <value>orSecond largest: None
Constraints
- 1 ≤ number of integers ≤ 100
- -1000 ≤ each integer ≤ 1000
Sample Test Cases
Sample 1
Input
4 9 2 9 7
Output
Largest: 9 Second largest: 7
Sample 2
Input
5 5 5
Output
Largest: 5 Second largest: None
Submitting checks 2 sample cases and 4 hidden test cases.