Creating List out of old List based on IF ELIF ELSE Python

Been trying to figure this out for ages and cant seem to make any progress, i have a list of items and depending what statement they meet i want them outputted however this is working but its only outputing the last item in the list and not producing all the results. How would i go about doing this?

Kind Regards - Bladen

My Nodes:

My Script

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
list = IN[0]
Result = None


# Place your code below this line
for list in list:
	if list == "2 Returns":
		Result = ["true", "true"]
	elif list == "LH Return":
		Result = ["true", "false"]
	elif list == "RH Return":
		Result = ["false", "true"]
	else:
		Result = ["false", "false"]
	

# Assign your output to the OUT variable.
OUT = Result

Hi @Bladen ,

I would highly recommend using a Dictionary, they are great for this! :smiley:

2022-04-12 Dictionary.dyn (11.7 KB)

2 Likes

That method worked perfectly, thank you! I was unaware of dictonarys so will be using them from now on!

1 Like

it would be good with python dictionary as well