본문 바로가기
python-algorithm

백준 3040 백설 공주와 일곱 난쟁이

by 무적김두칠 2021. 8. 19.

1
2
3
4
5
6
7
8
9
10
11
12
tmp=[]
for i in range(9):
    tmp.append(int(input()))
for i in range(9):
    for j in range(i+1,9):
        if sum(tmp)-tmp[i]-tmp[j]==100:
            x,y=i,j
            break
tmp.pop(x)
tmp.pop(y-1)
for i in tmp:
    print(i)
cs

x번째 index를 pop하면 리스트의 길이가 하나 줄어드니
y-1번째 index를 pop해야함.

list. pop("index")

list.remove("value") 

pop과 remove의 간단한 차이입니다.

반응형

'python-algorithm' 카테고리의 다른 글

백준 11650 좌표 정렬하기  (0) 2021.08.23
백준 2702 초6 수학  (0) 2021.08.19
Leetcode Add Strings  (0) 2021.08.19
Leetcode 4. Median of Two Sorted Arrays  (0) 2021.08.19
Leetcode 1822. Sign of the Product of an Array  (0) 2021.08.19

댓글