[프로그래머스] 추억점수 python

유진·2025년 7월 22일

coding-test

목록 보기
1/1

https://school.programmers.co.kr/learn/courses/30/lessons/176963

처음에는 name, yearning을 zip이나 dict으로 묶어야하나 싶었다
하지만 인덱스가 생각나서 묶지 않았다.

당연히 output은 photo리스트 안의 추억점수이니 전체 반복문은 photo로 해준다.

def solution(name, yearning, photo):
    answer = []
    
    
    for i in photo:
        cnt =0
        for j in i:
            if j in name:
                # print("있다")
                y = yearning[name.index(j)]
                # print(y)
                cnt=cnt+y
        answer.append(cnt)
    
    return answer
profile
안드로이드... 좋아하세요?

0개의 댓글