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.
if__name__=='__main__':students=[]for_inrange(int(input())):name=input()score=float(input())students.append([name,score])# Get the sorted list of unique scoresscores=sorted(set(scoreforname,scoreinstudents))# Ensure there are at least two unique scoresiflen(scores)>1:# The second lowest score would be the second element in the listsecond_lowest_score=scores[1]# Find all students with the second lowest scoresecond_lowest_students=[nameforname,scoreinstudentsifscore==second_lowest_score]# Sort the names alphabeticallysecond_lowest_students.sort()# Print each student's name on a new lineforstudentinsecond_lowest_students:# print(10*"-")print(student)else:print("There is no second lowest score.")
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 →