Checking for Equality:

  • Most conditional tests compare the current value of a variable to a specific value of interest.
1>>> university = "WCU"
2>>> university == "WCU"
3True
  • The first line above sets the value of university to “WCU” using a single equal sign (as you have seen many times already).
  • The second line above checks whether the value of university is “WCU” using a double equal sign (==). This equality operator returns True if the values on the left and right side of the operator match, and False if they don’t match.
    • A single equal sign is really a statement: “Set the value of university to ‘WCU’.”
    • A double equal sign asks a question: “Is the value of university equal to ‘WCU’?”