Given the names and grades for each student in a class of N students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.Note: If there are multiple students with the second lowest grade, order their names alphabetically and print each name on a new line.Go to problem statement.
Youtube Channel partner: CodingCart
Mentor: Satyendra Jaiswal
Source Code: Nested Lists solution
n=int(input()) res= grade= for i in range(n): name=input() mark=float(input()) res.append([name,mark]) grade.append(mark) #calculation 2nd lowest #print(res) #print(grade) grade=sorted(set(grade)) #sorted unique #print(grade) m=grade #print(m) name= for val in res: if m==val: name.append(val) #print(name) #unsorted name.sort() #print(name) #sorted for nm in name: print(nm)
Like this article? Follow us on Facebook and LinkedIn. You can also subscribe to our Youtube Channel.
This post is in partner with CodingCart.