Basic Python, can someone tell me why this wont find Success in list?

I know I can do this with nodes, just trying to learn and practice some python. It runs in an IDE. dont know what Im missing.

heres my code:

input = IN[0]
if input.count(“Success”)>0:
output = “(” + str(input[2]) + “)” + " Plans Exported"
if input.count(True) > 0:
output = “Operation was cancelled”
else:
output = “Error Running Script”
OUT = output

Instead of the second if statement, use elif and remove the empty lines between the statements. This will make your code check the first count, then if false it will try the next count and finally it will follow the else outcome.

As written currently, it checks the first if statement, which is not satisfied. By default in python if an else is not specified, it does nothing otherwise. It then goes onto the next if statement as a new one, and it is false, so it goes to the else (which is specified), and states an error has occured as the output.

1 Like

I literally just remembered that lol. I had thought it would take the first true and pass it and ignore the rest, but then I was like, elif exists for a reason then, eh? I didnt know line spacing mattered either! I was using it to just keep my statements easier to read through. Thanks!

1 Like

I believe line spacing wont matter necessarily, more of a code legibility thing there.

1 Like