Sep-13-2021, 08:47 AM
is
is used to determine whether two variable reference objects are the same (same memory address)==
is used to determine whether the value of the reference variable is equal (same value but different memory address)arr = [1, 2, 3] a = arr # a is point to the same object with arr (means same memory address) b = arr[:] # b is assigned the same value with arr print(a is arr) print(b is arr) # Here you will find that arr and a have the same memory address but not b print(id(arr)) print(id(a)) print(id(b))
Output:True
False
1897473154560
1897473154560
1897476673216