OneBite.Dev - Coding blog in a bite size

check if two variable is not equal in python

Code snippet on how to check if two variable is not equal in python

  if x != y:
      print("x is not equal to y")

This code checks if the variables x and y are not equal to each other. If they are not, then the statement “x is not equal to y” is printed in the console. First, the code checks if the value of x is not equal to the value of y. If this comparison is true, then the statement inside the if-block is executed. This statement prints the phrase “x is not equal to y” in the console. If the comparison is false, then the code inside the if-block isn’t executed and the code continues on to the next statement.

python