코딩테스트
프로그래머스 추억 점수 PYTHON
choyou831
2024. 7. 28. 10:01
- 추억 점
def solution(name, yearning, photo):
answer = []
count = 0
dic = dict(zip(name,yearning))
for i in range(len(photo)):
for j in range(len(photo[i])):
if photo[i][j] in dic:
count += dic[photo[i][j]]
answer.append(count)
count = 0
return answer
name과 yearning을 딕셔너리로 저장해준다음 photo에서를 순회하면서 이름에 추억도가 반영되있는경우 값들을 더해 answer에 추가해주었다.