'is' and 'is not' Operator

The “is” operator produces True if the values on either side of the operator refer to the same value. The “is” operator is particularly useful in determining if two variables refer to the same value in the computer's memory.

Check the program below to understand more about these operators

            main_course = "bread"
desert = "ice cream"
my_favorite = desert

print( main_course is my_favorite)
print( desert is my_favorite)
            

The 'is not' operator returns True if the values on either side of the operator are not the same. For example:

                my_name = "Sean"
my_freinds_name = "Mark"

print(my_name is not "Mark")
print(my_freinds_name is not "Sean")
                

it is conventional to use the comparison operator == when comparing values. The 'is' and 'is not' operators are primarily used for checking if two variables refer to the same location in the computer's memory.