인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

doctorsong8309's profile image
doctorsong8309

asked

Introduction to Python Algorithm Problem Solving (Coding Test Preparation)

3. Kth largest number

코드 오류 질문

Resolved

Written on

·

257

0

import sys
# sys.stdin = open('input.txt', 'rt')
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i<j<k:
                a = list(a[i-1]+a[j-1]+a[k-1])
                a.sort()
                print(a[-3])

저가 이렇게 하니 exit_code_1이 뜨는데 어느 부분이 잘못됬는지 궁금합니다.

python코테 준비 같이 해요!

Answer 2

0

doctorsong8309님의 프로필 이미지
doctorsong8309
Questioner

넵 이해했습니다. 답변 감사합니다~

0

codingcamp님의 프로필 이미지
codingcamp
Instructor

 a = list(a[i-1]+a[j-1]+a[k-1])    이부분이 잘못입니다.

print(list('7'))

print(list(7))

위 두 줄을 출력해 보세요. 

list() 함수는 정수를 인자로 받지 않습니다. 

인자로 문자열이나 a = list(map(int, input().split()))과 같이 map객체처럼 객체를 받아야 합니다. 

doctorsong8309's profile image
doctorsong8309

asked

Ask a question