def solution(name, yearning, photo):
answer = []
score = {}
for p in photo:
tot_score = 0
for person in p:
if person in name:
tot_score += yearning[name.index(person)]
answer.append(tot_score)
return answer
전에 푼 문제에서 .index() 함수를 쓰니 시간 초과가 났는데 이번 문제의 각 배열들의 길이가 그리 길지 않아서 그냥 사용했다.