I have a variables that I am trying to turn into a lambda function but I am struggling to get the input variable to work in the lambda expression.
My variables are:
function_name = 'add'
inpt = 'a,b,c'
and I want the output to be abc * 5 (a,b,c,a,b,c,a,b,c). However it is important that I use the variables rather than simply typing this.
I have tried to use a dictionary as such:
my_dict = {}
my_dict[function_name] =lambda inpt: inpt*5
However the output is a lambda function and I still have to manually enter the value of inpt instead of it taking the variable.
I am fairly new to programming so I may have misunderstood how the lambda function works. Any help would be appreciated.
lambda: inpt*5? It almost seems like you do not even need to give it a parameter.my_dict[function_name](inpt)