dimanche 14 mars 2021

Can't rectify a condition in the right way when there are multiple nots involved

I'm trying to combine multiple not conditions in a single line but I can't make it. This is how the conditional statements should be built upon:

when stat has a value and both the value of alternative and successor are nothing then only the script should print true.

When I try the following, I get true as the result.

stat = "o"
alternative = ""
successor = ""

if stat and not (alternative and successor):
    print("true")

However, When I execute the following, I also get true as the result

stat = "o"
alternative = "p"
successor = ""

if stat and not (alternative and successor):
    print("true")

How can I rectify the condition above to serve the purpose?

Aucun commentaire:

Enregistrer un commentaire