Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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))
print(a)

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading