Python script for if, else

hi everyone,
i just try a small python script. it doesn’t show any error, but output is null value.
anyone know. actually i trying to get a point value.
thanks

There are two issues I can see here.

  1. It appears you have a coverage gap in your if statements. This one is a bit harder, so we’ll put it off for a minute.
  2. The word “false” is not the same as the boolean value false. The boolean value false is called in python by typing False without quotes or wrapping of any kind.

Back to issue #1
You have two booleans, so it’s not too bad to just write out all possible values like this:
[[T,T], [T,F], [F,T],[F,F]]
Stepping through your if statements, we have 'if condition 1 is false, so we can remove those values from our set.
[[T,T], [T,F], [F,T],[F,F]]
The next if statement has ‘if condition 2 is false’, so we can remove that from our set.
[[T,T], [T,F], [F,T],[F,F]]

We’re left with a condition not caught where both values are true; you might not need this, but it’s important to cover, so providing another elif statement or an else statement. In some cases I’d use the ‘else’ to catch any errors, but here I think you can just return the value you’d want if the inputs were both true.

2 Likes