I wasn't able to find a satisfying answer anywhere so I decided to ask.
Let's say we have a global counter and a global list
counter=0
list=["function1","function2",..."functionN"]
we also we have those functions defined:
def function1():
pass
def function2():
pass
.
.
.
def functionN():
pass
I have an interface with a button, every time I press it, the global counter increments. Depending on the number, I need to call a different function. I can implement this with if and elif but I don't think it's that smart. Is there a way I can call those functions using the list?
Example
when counter=0=>list[0]=>the string is 'function1'=> call function1()
press button again
counter=1=>list[1]=>the string is 'function2' => call function2()
[function1, function2, ...]so that I can just calllist[counter]()directly?