I am new to python programming & was trying a hackkerank question based on nested lists to print the name(s) of any student(s) having the second lowest grade. Link for the question: https://www.hackerrank.com/challenges/nested-list/problem?isFullScreen=true Below is my code and I am getting unhashable type:'list' error:
if __name__ == '__main__':
i = int(input("Enter the length"))
name=[]
score=[]
for _ in range(i):
name.append(input())
score.append(float(input()))
my_list=[[name,score] for _ in range(i)]
us=list(set([score for name,score in my_list]))
us.sort()
if len(us)==1:
sl=us[0]
else:
sl=us[1]
student=[name for name,score in my_list if score==sl]
student.sort()
print(student)
Please advise what is wrong with this code. I have checked all articles regarding this error but nothing fixed it.