Change the output based on a condition

I’m trying to write a Python script so that the output changes depending on a specific condition.

I created a node using Python.Py3 (I’m using Rhinoceros 8).

I created 4 inputs:
A, B, C, and D.

A is a list of points.
B is a list of points.
C is a value to compare.
D is a value to compare.

If C is equal to D, the output should be the list of points that go into A.
If C is not equal to D, the output should be the list of points that go into B.

I’m having no success doing this.
I might not even need Python for this, but I don’t know how.

The script I created was this:

import rhinoscriptsyntax as rs

import ghpythonlib

# A, B are Tree Access

# C, D are Item Access

# 1. Function Definition

def select_list(A, B, C, D):

try:

    C_val = C

    D_val = D

except:

    C_val = C

    D_val = D

    

\# Lógica de seleção

if C_val == D_val:

    \# Return Data Tree B

    return B

else:

    \# Return  Data Tree A

    return A

# 2. Call the function and assign the result to the standard output variable

# Use ‘a’ or ‘out’ depending on how you named the component’s output!

# I’ll use ‘a’ as the default to avoid confusion.

a = select_list(A, B, C, D)

Change_the_output_based_on_a_condition.gh (7.9 KB)

This is what Stream Filter is for

(note that you can zoom in on the Filter component to add more inputs, but then you need to feed it a non-binary Gate value, which is not always straightforward)

Stream Filter.gh (7.0 KB)

Thank you very much