0
'list' object is not callable
lang: python Env: jupyter Error: 'list' object is not callable code: def add(x): return x+2 nums=[0,1,2] res=list(map(add,nums)) print(res) This is what exactly written in python map lesson. Please provide the solution. TIA
2 Respuestas
+ 7
Let me guess: you're using a variable named "list". In that case, you can't call the built-in function list() anymore. list() will now try to call your variable "list" and execute it like a function. That won't work. Remedy: Don't call your variables "list", "str", "set", "dict", "int", "float" etc.
/P.S. The variable "list" doesn't even need to be part of your current code since certain IDEs like Spyder (and probably Jupyter) save your variables and allow you to use the same variables in several codes. Remedy: find a button that says something like "remove all variables", click it and run the code again. If that doesn't help, restart the kernel
+ 1
Anna your explanation is kind aa I got to know out of box information. Thanks a lot for your time and patience to explain noob like me.