강의로 돌아가기
o920

TypeError: Object of type set is not JSON serializable 이런 오류는 왜 나나요?

TypeError: Object of type set is not JSON serializable 이런 오류는 왜 나나요?

작성중인 코드―solution.py
1
2
3
4
5
6
7
8
from itertools import combinations

def solution(numbers):
    s = set()
    li = list(combinations(numbers,2))
    for a in range(len(li)) :
        s.update({li[a][0]+li[a][1]})
    return s
  • Happytum

    return하는 데이터 형태가 리스트인 []가 아니라 {}라서 그런 것 같네여

    Happytum―2021.02.13 23:44
0 개의 답변
답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다.