help with nested lists

**Question: **Given the names and grades for each student in a Physics class of students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.

**My code: **

n=int(input())
list1=[]
for i in range(n):
name=input()
marks=input()
list1.append([marks,name])

a=min(list1)

for x in list1:
if x[0]==a[0]:
list1.remove(x)

b=min(list1)
c=[]

for x in list1:
if x[0]==b[0]:
c.append(x[1])
c.sort()

for x in c:
print(x)

I am getting some test cases failed. :frowning:

//