티스토리 뷰
[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
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 |