Search code examples
pythonmathlogical-operatorsimplication

Is there an implication logical operator in python?


I would like to write a statement in python with logical implication. Something like:

if x => y:
  do_sth()

Of course, I know I could use:

if (x and y) or not x:
  do_sth()

But is there a logical operator for this in python?


Solution

  • p => q is the same as not(p) or q, so you could try that!