0

How do I write a Python program for printing out second largest number given a list. For repeated numbers in the list, the code is supposed to return 'none'. This is the code I am writing:

i = int(input())
lis = list(map(int,raw_input().strip().split()))[:i]
z = max(lis)
while max(lis) == z:
    lis.remove(max(lis))

print (max(lis))
  • Does this answer your question? [Get the second largest number in a list in linear time](https://stackoverflow.com/questions/16225677/get-the-second-largest-number-in-a-list-in-linear-time) – Abdul Niyas P M Jan 10 '20 at 10:54
  • What exactly does *"for repeated numbers in the list, the code is supposed to return 'none'"* mean? Show example inputs and outputs. – deceze Jan 10 '20 at 10:57

0 Answers0