• + 0 comments

    Solution with explanation: First sort the nested lists in aplhabetical order. Make a separate set for marks ,remove duplicate values and sort it. The second element is the second lowest marks so now print the names that have second lowest marks.

    if name == 'main': stud=[] for _ in range(int(input())): name = input() score = float(input()) stud.append([name,score])

        # sort in alphabetical order of name
    _stud=sorted(stud,key= lambda x: x[0])
    
    
    marks=[] #stores marks
    for i in range(len(_stud)):
        marks.append(_stud[i][1])
    
        #removes duplicate values and arrange in descending order
    marks=list(sorted(set(marks))) 
    
    answer=marks[1]
    
    #print students with second lowest marks
    for i in range(len(_stud)):
        if(_stud[i][1]==answer):
            print(_stud[i][0])