1 | initial version |
A simple solution is to use tuples as indices, that is, x[(i,j,t)]
instead of x[i,j,t]
. They may have as many elements as you like.
2 | No.2 Revision |
A simple solution is to use tuples as indices, that is, x[(i,j,t)]
instead of x[i,j,t]
. They may have as many elements as you like.
As for the sum()
, it is enough to call it once, no matter how many summation indices you have inside - e.g.:
sum( x[(i,j,t)] for t in range(10) for i in range(5) for j in range(5) )