To compare if two numbers are the same, we use the equality operator, ==
.
5 == 5
When we compare the same numbers with the equality operator, the result is True
.
print(10 == 10)
When we compare the different numbers with the equality operator, the result is False
. Like here with the 9
to 10
comparison.
print(9 == 10)
To check if a string is equal to another string, we also use the equality operator, ==
.
print("apple" == "apple")