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.
You can actually be more pythonic and get rid of the for loop completely and only use list comprehensions all the way
n = int(input())
students = [[input(), float(input())] for i in range(n)]
second_lowest_score = sorted(list(set([i[1] for i in students])))[1]
print(*sorted([i[0] for i in students if i[1]==second_lowest_score]), sep="\n")
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 →
You can actually be more pythonic and get rid of the for loop completely and only use list comprehensions all the way n = int(input()) students = [[input(), float(input())] for i in range(n)] second_lowest_score = sorted(list(set([i[1] for i in students])))[1] print(*sorted([i[0] for i in students if i[1]==second_lowest_score]), sep="\n")