Suppose I had a string that could call any number of different functions depending on what its text is. Is there a way I could make it work without using loops a complex setup?
Here's an example of what I am trying to do, using simple add and subtract functions:
def add(num1, num2):
return num1 + num2
def sub(num1, num2):
return num1 - num2
first = 23
Second = 10
mode = "add" # could be "add", "sub" or other names of function #
mode(first, second) # would now call add() #