. Advertisement .
..3..
. Advertisement .
..4..
I get the “typeerror: object of type ‘int’ has no len()” issue when trying to create a code, when a user enters 7 digits, it multiplyes the numbers by 3 and 1, respectively. Here is the detail of the error I got the error message:
TypeError: object of type 'int' has no len()
Please give me some advice to solve this problem.
The cause: Perhaps it’s the issue with using
len()
on an integer value. Python does not have the len attribute. Solution: To fix the error, a function should be called on a list type of a variable.You should use the following:
Abstract:
This
error
error message is caused by you trying to call a method using aint
type variable. If you had called thelen()
function onlist
variable, this would work. Let’s examine the differences between these two situations:Fail:
This will cause an error similar as yours when you call
len()
on aint
variable type.Success:
Because you’re calling a function on
list
type variable, the above will work.