Remove Nulls in List

I’m trying to remove Nulls from a list with the clean list node but I can’t figure out whats wrong here?

Help very much appreciated!

Thx Rickard

Clear list from archilab

if you want to have same sequence , try use IsEmpty node before math.sum and filter the values, in order to apply Math.sum on only the value that have a numbers

Thanks for helping!
I like to try this without any packages, with that said I don’t really understand how to use the IsEmpty node. Can you please explain a little more?
I’ve also attached the DYN file

Hus A Total.dyn (7.4 KB)

set lacing in List.IsEmpty to longest

I still got 14 false values? :thinking:

@Reklund I was able to replicate your error. Try the following

Like This
empty values replaced by zeros so that the sum will not effected with them

Hello guys!
Both ways work perfectly! Thank you so much!

khuzaaimah.ElecEng: This makes sense to me, I understand this :slight_smile:

Salvatoreredragotta: It’s working perfectly, but I can’t understand why, care to explain? If not, thank you again. I appreciate the help!

  • Rickard
1 Like

Your list has empty strings at the end.


The List.Clean node doesn’t remove those. So you’ll have to replace empty strings with null, using conditional (similar to IF in revit formula) in a code block node:

item!="" ? item : null

!= mean does not equal.
"" and empty string

Why are you doing a check “if area is empty” rather than cleaning up your list?

Would it be more clear to just do that (removing nulls from list?) (in my case index 51).

Python script would be:

input = IN[0]
OUT = filter(None, input)

I agree with @3Pinter clean up before instead of at the end. Here is another solution