• + 1 comment

    Read the number of students

    n = int(input())

    Initialize an empty list to store students' name and grade pairs

    students = []

    Read the student data

    for _ in range(n): name = input() grade = float(input()) students.append([name, grade])

    Extract all the unique grades, sort them, and get the second lowest grade

    grades = sorted(set([student[1] for student in students]))

    Find the second lowest grade

    second_lowest_grade = grades[1]

    Find the names of students with the second lowest grade

    second_lowest_students = [student[0] for student in students if student[1] == second_lowest_grade]

    Sort the names alphabetically

    second_lowest_students.sort()

    Print the names

    for student in second_lowest_students: print(student)