Reputation: 921
I have a multidimensional matrix and want to set the last element to 1.(e.g. w[1,1,1,1,1]= 1)
The dimension varies, so thats my problem. po[-1]=1
doesn't work here.
Upvotes: 0
Views: 3605
Reputation: 249093
I'm going to assume you're using NumPy since Python itself doesn't have multidimensional arrays.
The easy way to do this is using a "flat" view of the array:
myarray.flat[-1] = 1
Upvotes: 6