0

I have this slice of Python code:

print(curr, nxt)
print (type(curr), type(nxt))
print (type(curr[0]), type(curr[1]))
print (type(nxt[0]), type(nxt[1]))

curr[0] = min(curr[0], nxt[0])
curr[1] = max(curr[1], nxt[1])
del condensed[i+1]

But when I run it, I get this output:

[3, 5] [4, 8] 
<class 'list'> <class 'list'> 
<class 'int'> <class 'int'> 
<class 'int'> <class 'int'> 

---> curr[1] = max(curr[1], nxt[1]) 

TypeError: 'int' object is not callable 

I don't understand what I am doing wrong, it seems like all the inputs to max() is fine. Furthermore, it never gets an error with min(). Any ideas?

If anyone wants to see the full code, it's on github and it's to solve this problem.

Moon Cheesez
  • 2,489
  • 3
  • 24
  • 38
joshualan
  • 2,030
  • 8
  • 23
  • 32

2 Answers2

4

You have a local or global variable called max. Therefore, Python was trying to use max (which was an integer) as a function.

Moon Cheesez
  • 2,489
  • 3
  • 24
  • 38
0

I've found my answer! I had max set as a variable somewhere else in that function, causing the namespace to be all messed up!

joshualan
  • 2,030
  • 8
  • 23
  • 32