Pyhon and List Length

I have this problem with Python, i dont can run correctly the python code, with the list length information.

Please help me!!!

Is it something to do with setting list access on your input?
Note that you can use for value in x to access the values directly

1 Like

yes, something is wrong with the acces the values of list lenght

i don´t know, what kind of option to select, if it is item acces, list access… en then, bool, float, str… a think there is the problem but i can´t solve it.

1 Like

i select this option, but but it generates another mistake

tough to see the error, but I would bet you need to set your type hint, (on the input connected to the honeybee component values), to FLOAT, not INT.

I have changed it but the error continues

You only really need one input (x) set to list access and then your code could be like this

for item in x:
   if item >0 and <98.69:
    #do something```
1 Like

post a sample file! Not one with the honey bee/plugin components, but a sample file.
Make some random numbers, and put them into you python component. Then post that file.
also, it looks like you might be trying to create/fine some ranges of values? ie, which values fall into which ranges…maybe?


FORMA.rar (1.9 MB)

I think you have changed the wrong entry. Set the type on x to list access and delete the count entry. Use my or @dharman’s looping method.

You can use count= len(x) if you need the length of x elsewhere in your script

1 Like

Ok, aside from the helpful advice you are receiving, here are a few other tips.

  1. When you post an example file, please try simplify it! (not with all the plugins, your question was about python, not honeybee)
    Note: you had the count set to tree access…if you are going to use it, set it to item.)

    2 - you can sort values using native components:
    (Screen shot has random values)

    3 - You can use some slighty more advanced python techniques to accomplish the same result as above, this particular example requires rhino 6. (but rule of thumb is…if you can do it with native components, maybe just use those?)

There are lots of folks on this forum that are happy to help, but it always starts with an example file and and, to the best of your ability, a brief description of the problem. (15.0 KB)