This article is part of in the series
Published: Tuesday 6th September 2016

In Python, comparison operators are used to compare the values on either side of the operators and then decide the relationship between them (sometimes they're also referred to as relational operators). What follows is a complete list of the comparison operators in Python. Some of them might be pretty self-explanatory, while others you may have never seen before.

Operator  Definition
== If the two values on either side of the operators are equal to each other, this returns as true (don't get == confused with =, in python the single equal sign, =, means assignment)
!= If the two values on either side of the operators are not equal, this becomes true.
<> If the two values on either side of the operators are not equal, this becomes true (this one is pretty similar to the != operator).
> Greater than. If the value to the left of the operator is larger than the value to the right, this becomes true.
< Less than. If the value to the left of the operator is less than the value to the right, this becomes true.
>= Greater than or equal to. If the value to the left of the operator is greater than or equal to the value on the right, this becomes true.
<= Less than or equal to. If the value to the left of the operator is less than or equal to the value on the right, this becomes true.