• + 0 comments

    not the best code but works,

    def lowest_in_list(list_name: list) -> int:
        low_item=list_name[0][1]
        for name, score in list_name:
            if score < low_item:
                low_item = score
        return(low_item)
    
    if __name__ == '__main__':
        students = []
        for _ in range(int(input())):
            name = input()
            score = float(input())
            students.append([name,score])
    
        #students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]
        lowest_marks=lowest_in_list(students)
    
        # new list to find the second lowest item
        second_list = []
        for name, score in students:
            if score != lowest_marks:
                second_list.append([name,score])
        second_lowest = lowest_in_list(second_list)
    
        names=[]
        for name, score in students:
            if score == second_lowest:
                names.append(name)
    
        for name in sorted(names):
            print(name)