-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnested-lists.py
More file actions
28 lines (23 loc) · 827 Bytes
/
nested-lists.py
File metadata and controls
28 lines (23 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
''' https://www.hackerrank.com/challenges/nested-list/problem '''
if __name__ == '__main__':
student_list = []
for _ in range(int(input())):
tmp = {}
tmp["name"] = input()
tmp["score"] = float(input())
student_list.append(tmp)
student_list.sort(key = lambda e : e["score"])
min_val = student_list[0]["score"]
second_min = None
filtered_list = []
for student in student_list:
if second_min != None and student["score"] > second_min:
break
if second_min == None and student["score"] > min_val:
second_min = student["score"]
filtered_list = []
if student["score"] == second_min:
filtered_list.append(student["name"])
filtered_list.sort()
for name in filtered_list:
print(name)