Python simple "if else" statement

Hello there,

I’m trying the following, but it always returns output a = input x, even if a = 0. I am working with integers and the type hint for x is set as such.

if x == 0:
    a = 1
else:
    a = x

print a

Covering tutorials and posts I also tried a different approach in the attached images, but it is not producing the desired result.
Any help is appreciated!

It could be something funky with the implementation (maybe you had a phantom variable, remember to attach your example file). Anywho, this seems to work as expected:


210416_Freddy_00.gh (2.4 KB)

Good to “see” you again :slight_smile:

I think mybe you have x set to List Access. Right click on the x to set it to Item Access.

2 Likes

Likewise Anders and thanks for the help!! The list access was the trouble maker.