304 North Cardinal St.
Dorchester Center, MA 02124

# Nested Lists Hacker Rank Solution – Queslers

## Problem: Nested Lists Hacker Rank Solution

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

• 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

5

Harry

37.21

Berry

37.21

Tina

37.2

Akriti

41

Harsh

39

Sample Output 0

Berry

Harry

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.

### Nested Lists Hacker Rank Solution Using Python 2

``````n = int(raw_input())
lst = []
for x in range(0, n):
lst.append([raw_input(), float(raw_input())])
lst = sorted(lst, key=lambda x: x);
for x in range(1, n):
if(lst[x] != lst[x-1]):
score = lst[x]
break
lst = sorted(lst);
for x in range(n):
if(lst[x] == score):
print lst[x]``````

### Nested Lists Hacker Rank Solution Using Python 3

``````if __name__ == '__main__':
students = []
for _ in range(int(input())):
name = input()
score = float(input())
students.append([name,score])
x = 99999
for i in range(len(students)):
if x > float(students[i]):
x = float(students[i])
y = 999999
for i in range(len(students)):
if float(students[i]) > float(x) and y > float(students[i]):
y = float(students[i])
runner = []
for i in range(len(students)):
if float(students[i]) == float(y):
runner.append(students[i])
runner = sorted(runner)

for i in range(len(runner)):
print(runner[i])``````

## Nested Lists Hacker Rank Solution Using Pypy

``````if __name__ == '__main__':
L=[]
n=int(raw_input())
for _ in range(n):
name = raw_input()
score = float(raw_input())
L.append([name,score])
k=[]
for i in range(n):
k.append(L[i])
k.sort()

i=1
while i<n and k==k[i]:
i=i+1
m=k[i]
s=[]
for j in range(n):
if L[j]==m:
s.append(L[j])
s.sort()
for z in range(len(s)):
print(s[z])``````

## Nested Lists Hacker Rank Solution Using Pypy3

``````if __name__ == '__main__':

arr = []
for _ in range(int(input())):
name = input()
score = float(input())
arr.append([score,name])
arr.sort()
for i in range(len(arr)):
if arr[i]> arr:
print(arr[i])

if i+1 >= len(arr) or arr[i+1] > arr[i]:
#print(arr[i+1])
break
#print (arr)
#print (arr)
#print (x)``````
##### Nested Lists Hacker Rank Solution Review:

In our experience, we suggest you solve this Nested Lists Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Nested Lists Hacker Rank Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Nested Lists Hacker Rank Solution.

##### Conclusion:

I hope this Nested Lists Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Staircase Hacker Rank Solution

A Very Big Sum Hacker Rank Solution

Diagonal Difference Hacker Rank Solution