Nested Lists - Python problem solution of HackerRank

Author: Al-mamun Sarkar Date: 2020-03-23 18:44:11

Nested Lists Python basic datatype problem - Python solution of HackerRank

Code:

if __name__ == '__main__':
    score_list = {}
    for _ in range(int(input())):
        name = input()
        score = float(input())
        if score in score_list:
            score_list[score].append(name)
        else:
            score_list[score] = [name]

    new_list = []
    for i in score_list:
        new_list.append([i, score_list[i]])

    new_list.sort()
    result = new_list[1][1]
    result.sort()
    print(*result, sep="\n")

Tesrt Input:

5
Harry
37.21
Bob
37.21
Tina
37.2
Akash
41
Harsh
39

Test Output;

Bob
Harry