Second Largest
Completed
Read a line of integers and print the second largest distinct value. If there isn't one, print none.
Input
One line of space-separated integers.
Output
A number or none.
Example
Input
3 1 4 4 2
Output
3
Editor
Python
Hints
A set removes duplicates.
After sorting, the second largest is at index -2.
Solution explanation
Removing duplicates first makes "second largest distinct" a simple index.
Show solution
nums = sorted(set(map(int, input().split())))
print(nums[-2] if len(nums) >= 2 else "none")