3
I am new in Python and I would like to know if it is possible to call a function by the text present in a variable, example:
I ask the user to enter the name of a function, and save what was typed in 'func' , after this how to call the function by what was typed by the user ?
func = input('Diga o nome da função a ser executada!')
func()
or - (Bearing in mind that the functions sum and mult 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 doesn’t work, but there’s something like this ?