Author -  Sai gowtham

Fix the 'int' object is not callable error in Python

In this tutorial, we are going to learn about how to fix the TypeError: ‘int’ object is not callable in Python.

This error occurs one of the following reasons:

  1. If you try to use an int() built-in function as a variable name.

  2. Calling the integer value as a function.

Here is an example:

# overriding the built-in float() function
int = 1

age = '12'
print(int(age))

Output:

TypeError:'int' object is not callable

In the above code, we have first initialized two variables one is int and second is age next we are converting the age string to a integer using the built-in int() function.So we are getting the error because we are using the int as a variable name and trying to call it as a function.

To fix the error, change the variable name to some other name, because int() is a built-in function in Python.So don’t override the built-in ones.

Here is an example:

user_id = 1
age = '12'

print(int(age)) #Output -> 12

Another cause of the error is calling a integer value like a function:

price  = 23

# TypeError: 'int' object is not callable
print(price())

Conclusion

The “int” object is not a callable error occurs, when we try to use the int as a variable name and calling the integer value as a function. To fix the error do not use the int as a variable name because it is reserved for int() function in python.

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY