Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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".

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading