-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathnested-list.py
More file actions
27 lines (20 loc) · 798 Bytes
/
nested-list.py
File metadata and controls
27 lines (20 loc) · 798 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
def get_students_with_grade(students, grade):
return list(filter(lambda student: student[1] == grade, students))
def get_second_lowest_grade(students):
unique_grades = set(map(get_grade, students))
ascending_grades = sorted(unique_grades)
return ascending_grades[1] # return second lowest grade
def get_grade(student):
return student[1]
if __name__ == '__main__':
students = []
for _ in range(int(input())):
name = input()
score = float(input())
students.append([name, score])
second_lowest_grade = get_second_lowest_grade(students)
students_with_grade = get_students_with_grade(
students, second_lowest_grade)
sorted_students = sorted(students_with_grade)
for name, _score in sorted_students:
print(name)