Replace null values of a list for 0

Hello,

Can someone help me?

I need make the null values in a list be zero

1 Like

@SdinizF ,

use a condition

x == null ? true : false

or replace

x == null ? 0 : item

in a codeblock

1 Like

Brilliant! Thank you

Your initial attempt was really close, so I’ll clarify where you went wrong: The condition input on ReplaceByCondition requires a Function to apply to the input items.

2 Likes

Replace Falsy by truevis replaces null or blank.

items = IN[0]
rep = IN[1]
elementlist = list()
for item in items:
	if not item:
		item = rep
	elementlist.append(item)
OUT = elementlist
3 Likes