Advertisement
j33vansh

Answer 5 Looping Py

Jun 26th, 2021
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. n =int(input())
  2. maxi = float("-inf")
  3. secondmax = float("-inf")
  4. count = 0
  5. if n!=0:
  6.     lst = [int(i) for i in input().split()]
  7. while count<n:
  8.     num = lst[count]
  9.     if num>maxi:
  10.         secondmax = maxi
  11.         maxi = num
  12.     elif num>secondmax and num!=maxi:
  13.         secondmax=num
  14.     count+=1
  15. if(secondmax!=float("-inf")):
  16.     print(secondmax)
  17. else:
  18.     print("-2147483648")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement