Error in list conversion in Python

Asked

Viewed 70 times

0

I have the following problem:

lista1 = [3,4,5]
list(map(lambda x: x**3, lista1))

Made that mistake:

TypeError Traceback (most recent call last)
<ipython-input-14-5e26f3f7b396> in <module>()
      2 lista1 = [3,4,5]
      3 lista2 = (map(lambda x: x**3, lista1))
----> 4 print(list(lista2))

TypeError: 'list' object is not callable

Could someone explain to me why I made a mistake?

  • Could you put in the full code, please?

  • @Andersoncarloswoss that’s the full code I run it on the notebook jupyter!

  • 2

    The code, as posted, no errors, so you must have run other things before, including setting a variable called list somewhere, overwriting the structure list Python standard, causing error.

  • @Andersoncarloswoss solved the problem by making a Restart in the notebook jupyter kernel

  • @Rafaelsilva take advantage and create an answer with your solution so that when someone has the same problem, learn how to fix it too.

  • In my case I was using the notebook jupyter and just doing the kernel Restart and everything started working.

  • @fernandosavio the answer was created.

  • Very good. Would you be able to add the command used to do this? I would do this, but since I don’t work much with Jupyter I don’t know how you do it.

  • And you can mark your answer as the correct one.

Show 4 more comments

1 answer

0

inserir a descrição da imagem aqui

@fernandosavio just press the button marked in red on the panel of the jupyter.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.