Miguel Guerreiro
Miguel Guerreiro

Reputation: 1

TypeError: 'tuple' object is not callable; range function

x = range(0, 10, 1)
print(x)
Traceback (most recent call last):

  Cell In[29], line 1
    x = range(0, 10, 1)

TypeError: 'tuple' object is not callable

I don´t sleep for over 24h and now I think I´m losing my mind. Can someone please tell me what could be wrong here...

I want to do this:

x_3741 = np.array(range(0, len(pim_3741), 1))

And it was working hours ago. Now I can´t even get the range function to work...

Upvotes: 0

Views: 499

Answers (2)

chara
chara

Reputation: 121

You have assigned a variable called range with a number, so the built in function was not called, rather python was trying to access your variable's values as a tuple i.e. with () brackets.

It worked when you restarted because the variables were cleared and you didn't happen to run the code that created the range variable in the first place. :)

Upvotes: 0

Maks Verver
Maks Verver

Reputation: 1127

You didn't provide sufficient details in the question to answer with certainty, but I suspect that you have assigned to range earlier in the code, replacing the builtin function definition with a tuple value.

Search for:

range = (1,2,3)

Or the like.

Upvotes: 1

Related Questions