I wrote a piece of code in python that reads a string, split it into 2 parts,the first being a string again and the second being an integer. For example
ABDKEK 1255443
The code is as follows:
L=raw_input()
ls=L.split()
num=int(ls[1])
L=ls[0]
len=len(L)
and it gives the following error
len=len(L)
TypeError: 'int' object is not callable
I make the following change in the code:
length=len(L)
and it works.
Can anyone explain what does the error 'int' object is not callable mean??
asked Dec 8, 2013 at 4:26
alphacentauri
1,0303 gold badges16 silver badges26 bronze badges
1 Answer 1
len is a function name which is already defined and should not be use as a variable. Try some other name instead.
answered Dec 8, 2013 at 4:28
doptimusprime
9,4416 gold badges59 silver badges95 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
alphacentauri
Thanks.... but I was asking the interpretation of the error.. as in..why the word 'int' was used.
lang-py
lenas a variable name. If you do, you'll no longer be able to access the builtin function namedlen. Note that you'll get the same error from, e.g.,3(2). An int cannot be called.