Get index number


#1

Hello :slight_smile:

I have this list :

How can I get the index number of nonempty index : Here I want the list {1;2;3;8;9} and another list with empty index {0;4…7;10…13}

Thank you :slight_smile:


#2

Start with this:


#3

Thank you tomasz,
I don’t know why but it doesn’t works


#4

That is because the line

if e is not None:

only works for “null” values, not empty strings.

try this instead:

if e == "":


#5

Yep I understand but it doesn’t work to.
Capture

remplace “” by " " do not change the error message :s


#6

please try
i == "":


#8

image


#9


#10

This is not exactly what I want
In your example I want the values : {0,1,2,3,5,7,8}
,but thank’s a lot !

I have found the solution to get empty index value :

Thanks all for your help !


#11

Great to hear, the reason the other wasn’t working was because of the double “” (quotes). We need to use single quotes to escape that.

image

"
lst = IN[0]
items = []
emp = []

for i, e in enumerate(lst):
	if lst[i] != '':
		items.append(i)
	else:
		emp.append(i)

#Assign your output to the OUT variable.
OUT = items,emp";

#12

@Sean1 Yes !!! That exactly what I want !!
Thank’s a lot Sean :wink: