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

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

# Nested Lists in Python - Hacker Rank Solution  # python2 solutionscore_list = []; # do not forget to declare a list
for _ in range(int(raw_input())):
    name = raw_input()
    score = float(raw_input())
        # Nested Lists in Python - Hacker Rank Solution START
    score_list.append([name, score])
second_highest = sorted(set([score for name, score in score_list]))[1]
print('\n'.join(sorted([name for name, score in score_list if score == second_highest])))# Nested Lists in Python - Hacker Rank Solution END

Tags:

Misc Example