2
We have the following functions:
def oi():
print('oi')
def ola():
print('ola')
Now let’s store them inside a dictionary as follows:
saudacoes = {
'chegada':{
'simples': oi(),
'cult': ola(),
}
}
I need to access the functions depending on two user inputs, the first says whether it is an arrival or farewell greeting and the second which greeting will be, so:
tipo, qual = input().split()
saudacoes[tipo][qual]
Let’s assume the user type:
> chegada simples
Therefore, the program should search in the dictionary as follows:
saudacoes[chegada][simples]
And you would expect him to perform the function oi()
. But nothing happens. Where I’m going wrong?