I have a list of strings which contains lambda functions like this:
funcs = ["lambda x: x * x", "lambda x: x + x"]
And I want to use these functions as we use lambda. If I had this for example:
funcs = [lambda x: x * x, lambda x: x + x]
a = funcs[0](3)
print(a)
> 9
But first I need to convert this string to a lambda
to use it as lambda
. How will I do that?