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.
deflowest_in_list(list_name:list)->int:low_item=list_name[0][1]forname,scoreinlist_name:ifscore<low_item:low_item=scorereturn(low_item)if__name__=='__main__':students=[]for_inrange(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 itemsecond_list=[]forname,scoreinstudents:ifscore!=lowest_marks:second_list.append([name,score])second_lowest=lowest_in_list(second_list)names=[]forname,scoreinstudents:ifscore==second_lowest:names.append(name)fornameinsorted(names):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 →
not the best code but works,