You are viewing a single comment's thread. Return to all comments →
if __name__ == '__main__': students = [] for _ in range(int(input())): name = input() score = float(input()) students.append([name, score]) sorted_arr = sorted(students,key=lambda item: (item[1], item[0])) lowest_score = sorted_arr[0][1] second_lowest_score = -1 for i in range( len(sorted_arr)-1): if (sorted_arr[i][1] != sorted_arr[i+1][1]) & (second_lowest_score == -1): second_lowest_score = sorted_arr[i+1][1] print(sorted_arr[i+1][0]) elif sorted_arr[i+1][1] == second_lowest_score: print(sorted_arr[i+1][0])
Seems like cookies are disabled on this browser, please enable them to open this website
Nested Lists
You are viewing a single comment's thread. Return to all comments →