doanhtu

Hacker rank Nested list

Oct 25th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. if __name__ == '__main__':
  2.     li = []
  3.     for _ in range(int(input())):
  4.         name = input()
  5.         score = float(input())
  6.         li.append((name, score))
  7.    
  8.     result = sorted(li, key=lambda x: x[1])
  9.     lowest_score = min(result, key=lambda x: x[1])[1]
  10.     second_lowest_score = 0
  11.     for name, score in result:
  12.         if score > lowest_score:
  13.             second_lowest_score = score
  14.             break
  15.    
  16.     names = sorted([name for name, score in result if score == second_lowest_score])
  17.     for n in names:
  18.         print(n)
Add Comment
Please, Sign In to add comment