<jupyter_start><jupyter_text>Basic Data Types<NAME>Exercise from [Hacker rank](https://www.hackerrank.com/challenges/nested-list/problem)  Nested Lists**Task**Given the names and grades for each student in a Physics 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 same grade, order their names alphabetically and print each name on a new line.**Input Format**The first line contains an integer, $N$, the number of students.The $2N$ subsequent lines describe each student over $2$ lines; the first line contains a student's name, and the second line contains their grade. **Constraints*** $2 \le N \le 5$* There will always be one or more students having the second lowest grade. **Output Format**Print the name(s) of any student(s) having the second lowest grade in Physics; if there are multiple students, order their names alphabetically and print each one on a new line.**Sample Input 0**```5Harry37.21Berry37.21Tina37.2Akriti41Harsh39```**Sample Output 0**```BerryHarry```**Explanation 0**There are $5$ students in this class whose names and grades are assembled to build the following list:```Python students = [['Harry', 37.21], ['Berry', 37.21], ['Tina', 37.2], ['Akriti', 41], ['Harsh', 39]]```The lowest grade of $37.2$ belongs to Tina. The second lowest grade of $37.21$ belongs to both Harry and Berry, so we order their names alphabetically and print each name on a new line.  My implementation At first I wanted to sort the nested list by the second value of each list. I found in internet a way to sort it using a `key` in the function `sorted()`. Then, knowing that the lowest score can be repeated, I remove all the values that were the same as the last one. Finally I used a list comprehension to take the names of the values equal to the second lowest grade and sorted them to fullfil all the conditions.<jupyter_code>if __name__ == '__main__':

    students = []

    for _ in range(int(input())):
        name = input()
        score = float(input())

        students.append([name, float(score)])
        
    students_sorted = sorted(students, key= lambda item : item[1])
    
    new = []
    
    for i in students_sorted:
        
        if (i[1] != students_sorted[0][1]):
            new.append(i)    
        
    students_names = [new[i][0] for i in range(len(new)) if new[i][1] == new[0][1]]
    
    print()
    
    for name in sorted(students_names):
        print(name)<jupyter_output>5
Harsh
20
Beria
20
Varun
19
Kakumi
19
Vikas
21

Beria
Harsh<jupyter_text>Best implementation in the discussion In this implementation, a helper `list` is created to find the value of the second lowest note. Then just look which value(s) are equal to the value and print it (them). The use of the helper list reduce the `for loops` that I had to use<jupyter_code>if __name__ == '__main__':

    marksheet = []
    scorelist = []

    for _ in range(int(input())):
        name = input()
        score = float(input())
        marksheet += [[name, score]]
        scorelist += [score]
    
    second_low = sorted(list(set(scorelist)))[1] 

    print()
    
    for name, grade in sorted(marksheet):
        
        if (grade == second_low):
            
            print(name)<jupyter_output>5
Harsh
20
Beria
20
Varun
19
Kakumi
19
Vikas
21

Beria
Harsh
{'fraction_non_alphanumeric': 0.09723040659988215, 'fraction_numerical': 0.022687094873305835, 'mean_word_length': 3.514627659574468, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '178316', 'license': 'MIT', 'n_tokens_mistral': 1052, 'n_tokens_neox': 982, 'n_words': 438, 'path': '02_basic_data_types/03_nested_list.ipynb', 'repo_name': 'juanhenao21/hack_rank', 'size': '3413'}