This my code:
num= [2,10]
def calculo(lista):
lista2 = []
for i in lista:
for j in range(1, i + 1):
if i % j == 0:
lista2.append(j)
return lista2
print(calculo(num))
Which produces: [1, 2, 1, 2, 5, 10]. However, I need the following result:
[[1, 2], [1, 2, 5, 10]]
In addition, I would like to know your approach through list comprehension.