Python len() function reporting 'float' error when handling a list

I have a list of lists that I initiate as follows:

patches = [[]]

and then I append to main list by patches.append(list_of_x), and to the sub lists I append objects by patches[i].append(x).

When I call len(patches) I get error "’float’ object is not callable".

I did verify by type(patches) that Python still considers this a list.

The objects within the sub-lists patches[i] themselves have variety of different attributes, but I think that should be irrelevant (right?).

Any idea what kind of witchcraft could be happening?

>Solution :

I think you might have defined a variable called len before that in your code. And this variable is probably a float, which, as the error says, you can’t call.

Leave a Reply