티스토리 뷰

Hackerrank/Python

Nested Lists

.   2022. 2. 6. 03:49

[2, 5] 범위의 정수 N을 입력 받는다.

이름과 성적을 두 줄에 걸쳐서 N개 만큼 입력받는다.

두번째로 낮은 성적을 받은 학생(들)을 출력한다.

if __name__ == '__main__':
    min1 = 999
    min1List = []
    min2 = 999
    min2List = []
    for _ in range(int(input())):
        name = input()
        score = float(input())
        
        if score < min1:
            min2 = min1
            min1 = score
            min2List = min1List
            min1List = [name]
        elif score == min1:
            min1List.append(name)
        elif score < min2:
            min2 = score
            min2List = [name]
        elif score == min2:
            min2List.append(name)
            
    min2List.sort()
    for i in min2List:
        print(i)

Nested Lists | HackerRank

 

Nested Lists | HackerRank

In a classroom of N students, find the student with the second lowest grade.

www.hackerrank.com

 

 

'Hackerrank > Python' 카테고리의 다른 글

Finding the percentage  (0) 2022.02.06
Find the Runner-Up Score!  (0) 2022.02.05
List Comprehension  (0) 2022.02.05
Print Function  (0) 2022.02.05
Write a function  (0) 2022.02.05
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함