I'm new to Python and I'd like to know if it's possible for me to call a function by the present text in a variable, for example:
I asked the user to enter the name of a function, and save what was typed in 'func' , after that how to call the function that the user typed?
func = input('Diga o nome da função a ser executada!')
func()
or - (Keep in mind that add and mult functions are already done)
func = 'somar'
result1 = func(3, 2)
func = 'mult'
result2 = func(3, 2)
print('O resultado é', result1, result2)
#---gostaria que resultasse
O resultado é 5 6
I know this does not work, but is there anything like this?