On a Linux Debian 12 with Python 3.11.2,
I get this :
l = [ 1, 2, 3 ]
min(l)
1
max(l)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
Why the max() function doesn’t work ?
Thanks.
I expected that max(l) return 3
>Solution :
I think you must have reassigned the builtin max function of python, to a integer, hence creating a new max(int variable), it could have happened like this
max = 5
l = [1,2,3]
max(l)
that’s why you could have gotten the error that "int" object is not callable, you try
- changing you code, (not declaring a max variable)
- Restore the Built-in max Function:
import builtins
max = builtins.max
For more information, you can try sharing the code snippet.