본문 바로가기
코딩테스트 파이썬/파이썬 프로그래머스 2단계

튜플

by 세용용용용 2023. 7. 7.

def solution(s):
    answer = []
    s = s.split('},{')
    s[0] = s[0].replace('{','')
    s[-1] = s[-1].replace('}','')
    #print(s)
    s.sort(key=len)
    for i in s:
        i = i.split(',')
        for j in i:
            if int(j) not in answer:
                answer.append(int(j))
    #print(answer)

    return answer
solution("{{2},{2,1},{2,1,3},{2,1,3,4}}")

'코딩테스트 파이썬 > 파이썬 프로그래머스 2단계' 카테고리의 다른 글

기능개발  (0) 2023.07.08
할인행사  (0) 2023.07.08
의상  (0) 2023.07.07
괄호 변환  (0) 2023.06.13
무인도 여행  (2) 2023.06.09