steeeve - 7 months ago 41

Python Question

I have a function that accepts user parameter k and generates a matrix of the form:

`a = np.array((k,2,5))`

Leaving the function I would like to return

`if k == 2:`

return a[0,:,:], a[1,:,:]

if k == 3:

return a[0,:,:], a[1,:,:], a[2,:,:]

Is there a way to do this dynamically without having to hard-code each of the possible values of k?

Thanks.

Source (Stackoverflow)