I have an array of functions and I want to call them by their index. However the following code gives me an error(TypeError: 'list' object is not callable)
kFunc = [Row(a,value, row), Col(a,value,col), Gridval(a,value, row, col), Grid(a, value), Rectangle(a, value, row, col) ]
k = random.randint(1,4)
for j in range(k):
output = kFunc[j]()
Each function returns a value. I tried replacing kFunc[j]()
with kFunc[j]
. I didn't get any error but all the 5 functions are getting executed.
I found a similar question here but I can't figure out an answer to my question.
I'd appreciate any help. Thanks