How to merge 2 list based on a condition, how?

Hello,

i wanna merge 2 lists based a condtion x == 0 ? y : x
But for any reson it does not work, what can i do?

KR

Andreas

Can you show us the output? Right now you’re showing just the input y.

1 Like

@Nick_Boyts ,

The preview of a code block only shows the last line. Right now your last line is just y; so you’re essentially just returning the input again. Your condition may already be working correctly, you just aren’t looking at it.

1 Like

@Nick_Boyts


i wanna replace each 0.0 from the other list.

(python does not work :wink: )

Change your code block to just this:

x >= 0.0 ? y : x;

@Nick_Boyts ,

it does not work…

is there a pythonway ?

#if 0 take Item from List2 else remain in List1

Are you sure both inputs are numbers?

The python you have should work but you’re only checking for == and not >=.

@Nick_Boyts ,

all clean doubles
grafik

What does your python error say? It looks like you haven’t zipped your inputs.

for i,x in zip(IN[0],IN[1]):

1 Like

And that goes for both inputs?

@Nick_Boyts ,

grafik

i used these nodes, for any reason i had “empty values” as string… right no they are clean!

KR

Andreas

@Nick_Boyts ,

in python works!

# Phython-Standard- und DesignScript-Bibliotheken laden
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Die Eingaben fĂĽr diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
dataEnteringNode = IN

# Code unterhalb dieser Linie platzieren
lis1 = IN[0]
lis2 = IN[1]

output = []

for i,x in zip(lis1,lis2):
	if i == 0:
		output.append(x)
	else:
		output.append(i)
		

OUT = output

Seems like your code block should have worked by using the <=. Anyway glad you resolved!

1 Like

@staylor ,

yes you i right… for any reason in this variation it works…

1 Like