0
Hi, I’m developing a program that gets a list of bases and exponents. Thus, it performs the potentiation between them and, soon after, multiplies the results. However, I am dubious about the multiplication of results. So far, I have been able to develop this:
def potenciacao(Bases,Expoentes):
#Recebendo as Bases e Expoentes, ambas armazenadas em listas e possuem o mesmo tamanho
resultados = [Bases[i]**Expoentes[i] for i in range(len(Bases))]
# Realizando a potenciação entre eles com um list comprehension
Resultado = map(lambda x,y = x*y,resultados)
# Pensei em utilizar a função map do python para realizar isso, mas não consegui
return Resultado
Is there a python function that performs this type of operation with lists? Or some method?
Do you need to multiply the results? Wouldn’t you add them up? By the way, the
map
does not do what you want, it is probably thereduce
that you need.– Woss
Yes, I need to multiply the values contained in the 'results' list'.
– Ricardo Gomes
Thanks in advance, from the function
reduce
I was able to accomplish what I needed– Ricardo Gomes