Python Practice Lab
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> or Second 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.

Hints

Saved
Custom 1

This is your own input, so Run will show what your program prints but can't say whether it's correct.