Programming/프로그래머스

[프로그래머스] 행렬의 합

pental 2020. 10. 12. 21:12

def solution(arr1, arr2):
    result = []
    temp = []
    for i in range(len(arr1)):
        for j in range(len(arr1[i])):
            temp.append(arr1[i][j] + arr2[i][j])
        result.append(temp)
        temp = []
    return result

for문에서 사실 애먹었다;;

for i in range(len(arr1)): #arr1의 요소 2개 (2번 돈다.)
	for j in range(len(arr1[i)) # arr1의 요소 안의 요소
    	temp.append(arr1[i][j] + arr2[i][j]
    result.append(temp)
    temp = []		#요소를 묶기 위해