Page 1 of 1

Python: Identity Operators

Posted: Tue Oct 28, 2025 8:42 pm
by The Jason

Code: Select all

# Note: identity Operators do not tell if variables contain the same contents, but rather if they point to the same object

color_list_1 = list((orange, green, yellow, black, white, grey))

color_list_2:= list((pink, red, purple, brown))

color_list_3 = color_list_1

color_list_4 = list((pink, red, purple, brown))

print(color_list_1 is in color_list_3)

# The output is True

Code: Select all


print(color_list_2 == color_list_4))

# The output is True because of exact same content.

print(color_list_2 is in color_list_4)

# The output is False because they contain the same stuff but do not point to the same object.