Here is the code
marksheet = []
for _ in range(0,int(input())):
marksheet.append([input(), float(input())])
second_highest = sorted(list(set([marks for name, marks in marksheet])))[1]
print('\n'.join([a for a,b in sorted(marksheet) if b == second_highest]))
Doesn't the [marks for name, marks in marksheet] produce the same list as marksheet? So couldn't we get the same result with second_highest = sorted(list(set(marksheet)))[1] ?