Python throws the error, ‘int’ object is not callable when you try to call an integer as function. This happens when you use reserved keywords as your variable name or override library functions with integer variables.
round() is the function which is used to round the number to the nearest integer. Now if we declare an integer variable with name
round, then within the scope of that variable, we won’t be able to use
round() function. Check this code –
round = 5; round(5 * 3 / 2); // TypeError: 'int' object is not callable.
The above code will throw TypeError: ‘int’ object is not callable.
The solution to this problem is to keep a close eye on your variable names. Avoid using very common names which could match the general functions. Have a little understanding of Math functions and reserved keywords.
You can’t use these keywords as your variable names. So if you try to use them, you will get the error.
Demo might not work in private window (Incognito)