range function doesn't work in jupyter notebook


I use jupyter notebook in vscode.
I execute the simple code in Jupyter notebook(.ipynb)

a = list(range(10))

The code execution result is…

TypeError                                 Traceback (most recent call last)
<ipython-input-27-b9f6d3d8e065> in <module>
----> 1 a = list(range(10))
      2 print(a)

TypeError: 'range' object is not callable

but, The code is executed well in Python file(.py)

of course, The code execution result is…

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

It’s an error that I don’t understand. I want to avoid not being able to use Jupiter notebook because of this problem. I ask for your help.


You may have already defined list,range varable, try to restart your notebook.

list = range(10)
>>> list(range(10))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'range' object is not callable

Answered By – Kamel

Answer Checked By – Dawn Plyler (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.