Python Grasshopper question

Hello guys,
I’m recently developing my own componet, but faced into a small problem. I usually use “len()” function to do a loop but this time it doesnt work dont know why, showing an error “float is not callable”. It works in other scripts but this time.

Hope someone can help this small problem.
Many (3.2 KB)

There isn’t a len() function in your posted script. However it fails on:

You don’t need the range(), just use:


Hello Jeremy,
Thanks for your reply, Sorry I attach the wrong file.
Here is the correct (5.6 KB)

In line 21 of the script you overwrote the Python len function by mistake with something else. You should never use the in built function names. Choose a different name there.

I agree with Jeremy on this. If you need the point and its index you can use for i, pt in enumerate(pts):

It is faster, clearer and more “pythonic”

Best regards


Hi @kai.yeh,

@fin has correctly identified the reason why len() isn’t doing what you expected and @Dancergraham has reiterated that a python for loop takes care of the size of the list for you so the len() is unnecessary. Nothing for me to add!

Good luck with your ventures into Python.