Error With List Index Of

Hi All
I Try To Get The Number Of Index But At Left Side It Didn’t Work As In Right Side
What I Doing Wrong
Thanks Sarah

What output are you expecting on the left side? List.IndexOf only returns the first index of an element found in the list. For example, you have a list like this:

[4, 4, 4, 4, 4, 4]

And you are searching for each of the following values in that list:

[4, 4, 4, 4, 4, 4]

Because there is already a 4 at the beginning of the list (index 0) it is returning 0 for every number.

1 Like

First of all thanks for your help
My question now how can I get the index number I need to get an integers from the list ,
If the list list is [4,4,4,4] I need to get the index value as a string or as a number [0,1,2,3] how can I get this value???
Thanks sara

It sounds like you might want to use the List.AllIndicesOf node, but depending on your lacing this will create a lot of extra results. For example, if your list is [4, 4, 4, 4] and your items are contained in an identical list [4, 4, 4, 4], your result will be [0, 1, 2, 3] for each number in the second list.

Here’s another example where there is a complete match for the first list of the “item” input and a partial match for the for the second list of the same input:

You can see that 2, 3, and 4 are not present in the list [5, 5, 5, 0] (as shown by the empty lists) and that the last number (5) is found at indices 0, 1, and 2.

3 Likes

Thanks a lot @cgartland :heart: