Home > Backend Development > Python Tutorial > Why Am I Getting a \'TypeError: \'int\' object is not callable\' Error with `round()`?

Why Am I Getting a \'TypeError: \'int\' object is not callable\' Error with `round()`?

Susan Sarandon
Release: 2024-12-04 13:40:10
Original
950 people have browsed it

Why Am I Getting a

Object Call Error: 'int' Not Callable

The provided code snippet:

a = 23
b = 45
c = 16

round((a/b)*0.9*c)
Copy after login

encounters a TypeError: 'int' object is not callable.

This error indicates that the round() function is not recognized as a callable object. This is because another variable or value in your code has been assigned to the name round, overwriting the built-in round() function.

The root cause of this issue is a code elsewhere in your program that assigns an int to round, such as:

round = 42
Copy after login

When you then call round((a/b)0.9c), it attempts to call a function on the int value round, which is not callable.

To resolve this issue, locate the code that assigns an int to round and remove or modify that assignment. This will restore the built-in round() function to its proper binding.

The above is the detailed content of Why Am I Getting a \'TypeError: \'int\' object is not callable\' Error with `round()`?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template