알고리즘 문제/CodeWar

Multiplication table

BEstyle 2022. 10. 4. 01:32

DESCRIPTION:

Your task, is to create NxN multiplication table, of size provided in parameter.

for example, when given size is 3:

1 2 3
2 4 6
3 6 9

for given example, the return value should be: [[1,2,3],[2,4,6],[3,6,9]]


def multiplication_table(size):
    ansList=[]
    temp=[]
    for j in range(1,size+1):
        for i in range(1,size+1):
            temp.append(i*j)
        ansList.append(temp)
        temp=[]
    return ansList