Codeblock for more than one statement

This is probably an easy question for most of you.
I have little to no knowledge about python.

I am trying to make a codeblock that checks wether or not the first input is either a 0, 1 or 2. And than i want the codeblock to output one of multple inputs associated with the number 0,1 or 2.

I think the image below explains what i am trying to do better…

Like this?

Yes almost,
I need to have 4 inputs for those values because they will be lists of values.

I used strings as input to simplify it for my question

you can change the input “a” to whatever you want, those || are just or statements (&& = and)

1 Like

I am sorry for not being able to follow this…

But i need the output values be lists that are passed through this node based on those statements. The image i attatched explains this better…

i am not sure how to add 3 extra inputs in the example Vijay gave…

You need to get rid of the : in your last line.

1 Like

Have you considered using GetItemAtIndex? You are in a good position of already having 0,1,and 2 to represent indices.

This is actually the way you’ll need to go if you’re passing entire lists, but the immediate issue with your code block is the open “then” statement I mentioned in my previous response.

Hi @Nick_Boyts Nick,
Thank you for your responce.
If i remove the : i get this message:

What @Robert_Younger Robert said is something i completely missed… Not sure why i didnt think of that… That solves this problem without even using that code block.
Thanks!

Just for my understanding though, You cant pass lists through the codeblock i made?

Sorry, I assumed your last line was the final argument but you’re actually missing one entirely. You’re nesting If/Else statements, but your last statement only has an If. You need to provide an Else option for if a doesn’t equal any of those values.

You can use lists as inputs for an If statement but it processes each input individually so it won’t ever output entire lists. It depends on what you’re trying to return as an output.

Hi Nick

Thank you again, will try it again.

What you are seeing is part of a pdf plot script.
This part specifically is to enter the correct pdf file name, we have a standard way of naming drawings and project specific way of naming files.

This is controlled by a radio button input from data shapes.
I can’t make data shapes send the file names directly since this creates a loop(because sheets are selected in the same pop up window) which means dynamo is trying to read parameters from sheets that aren’t there yet.

I figured I would make this code block to pass the correct filenames based on the radio button output (0,1 or 2)