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.
I think there is something wrong with the compiler. I made some changes to your code to run the rest of the test cases and made some changes:
final = []
n = int(input())
for _ in range(n):
name = input()
score = float(input())
l = [name, score]
final.append(l)
final.sort()
need = final[1]
for i in range(n):
if(final[i][1] == need[1]):
print(final[i][0])
When I ran it on a offline IDLE compiler all outputs are correct but when I ran it on HackerRank, it shows scores instead of names.
Nested Lists
You are viewing a single comment's thread. Return to all comments →
I think there is something wrong with the compiler. I made some changes to your code to run the rest of the test cases and made some changes:
final = [] n = int(input()) for _ in range(n): name = input() score = float(input()) l = [name, score] final.append(l) final.sort() need = final[1] for i in range(n): if(final[i][1] == need[1]): print(final[i][0])
When I ran it on a offline IDLE compiler all outputs are correct but when I ran it on HackerRank, it shows scores instead of names.