0

'I'm having problem with same code on different Jupyter notebook, one note runs the code with out any error in one it throws an error -->TypeError: 'range' object is not callable

Output i got with a notebook: [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

In other notebook: TypeError Traceback (most recent call last) in ----> 2 list_1 = list(range_1)

TypeError: 'range' object is not callable'

Can anyone help me out with this?

range_1 = range(10,20)
list_1 = list(range_1)
print(list_1)

  • I guess you re-assigned `list = some_range_object` somewhere, and after that the `list` is no longer callable. Here is another thread on how to restore the original: [link](https://stackoverflow.com/questions/17152760/how-to-restore-a-builtin-that-i-overwrote-by-accident) – qrsngky Apr 14 '23 at 07:21
  • Welcome to Stack Overflow. What is the difference between the two notebooks? – ewokx Apr 14 '23 at 07:22
  • I guess in jupyter new file is called as notebook, correct me if i'm wrong – Sandeep Karunanithi Apr 14 '23 at 07:43
  • are you sure you aren't calling the range function anywhere else in the notebook that's failing? – Kulasangar Apr 14 '23 at 08:56
  • I have used range function in the same notebook but did not call it , but here i have used different variable for this range (different range that what i used earlier) and wanted to print that as list, here i have uploaded my notebook https://github.com/SandeepKaruna/Python/blob/main/Extra%20Assignment%20Level%20-1%20%26%202%20%28Python%29.ipynb – Sandeep Karunanithi Apr 14 '23 at 09:20

0 Answers0