We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hi everyone, this is my solution to the problem.
It is not the shortest or most elegant, but I hope it is brief and clear
#Generate nested list from imputnested_list=[]for_inrange(int(input())):#read input into the nested listnested_list.append([input(),float(input())])#Sort the list by second index or gradenested_list.sort(key=lambdax:x[1])#take the garade of the first element in the sorted listlowest=nested_list[0][1]#in case the grades look like 21,21,21,23,25...forname,gradeinnested_list:#iterate the sorted list ifgrade!=lowest:# until you find the first grade different from the lowestsecond_lowest=gradebreak#Sort the list by first index or name nested_list.sort(key=lambdax:x[0])#Print all the names with second lowest gradeforname,gradeinnested_list:ifgrade==second_lowest:print(name)
Cookie support is required to access HackerRank
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 →
Hi everyone, this is my solution to the problem. It is not the shortest or most elegant, but I hope it is brief and clear