I’m trying to solve this problem but i keep getting ~no response on stdout~ even though it functions properly with the correct output in visual studio code. The problem specifically asks us to print, and all of the solutions in the comments use the print function for output.
Here is my code :
if __name__ == '__main__':
students = []
for _ in range(int(input())):
name = input()
score = float(input())
students.append([name,score])
students.sort(key = operator.itemgetter(1))
minstd = students[0][1]
for student in students:
if student[1] == minstd:
students.remove(student)
finallist = []
for student in students:
if student[1] == students[0][1]:
finallist.append(student[0])
finallist.sort(key = operator.itemgetter(0))
print(*finallist, sep = 'n')
Thanks in advance.
The issue : as pointed down in a response : the issue was that hackerrank needs you to import operator where as vscode doesn’t
2
Answers
I can’t see the definition of ‘students’ identifier in your code
if you just wanna pass the hackerrank
just type this code, i got from discussions, because you didnt set variabel students and operator