I have two user defined functions, like this:
def test_sum(a,b):
x = a+b
return x
def test_mean(a,b,c):
z = a+b+c
return z
using dictionary, based on the user interest one of the function is selected
func = {
'sum_test': test_sum,
'mean_test': test_mean
}
user_input = 'sum_test'
if user_input in func:
print(func[user_input](10, 15))
How to pass the function arguments dynamically similar to how function is selected by user? (For the test_sum
function I know there are two arguments so I gave 10, 15
, but for the test_mean
function there are three arguments so I have to change 10, 15
to 10, 15, 20
and I have to do this every time when a function changes.)