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

의상

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

def solution(clothes):
    answer = 1

    dict_clothes = {}
    for i in clothes:
        if i[1] not in dict_clothes:
            dict_clothes[i[1]] = 1
        else:
            dict_clothes[i[1]] += 1
   

    for i in dict_clothes.values():
        answer = answer*(i+1)
    answer -= 1
    #print(answer)
    return answer
solution([["yellow_hat", "headgear"],
          ["blue_sunglasses", "eyewear"],
          ["green_turban", "headgear"]])

 

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

할인행사  (0) 2023.07.08
튜플  (0) 2023.07.07
괄호 변환  (0) 2023.06.13
무인도 여행  (2) 2023.06.09
방금그곡  (0) 2023.06.08