1

I'm bit confused with this logic. When the following gives True in python

print('' is '')  #True
print('' == '')  #True
print([] ==  []) #True
print({} ==  {}) #True

But why these statement gives False?

print([] is  []) #False
print({} is  {}) #False
Vanjith
  • 520
  • 4
  • 23

1 Answers1

6

The == operator compares the values of both the operands and checks for value equality. Whereas is operator checks whether both the operands refer to the same object or not.

https://www.geeksforgeeks.org/difference-operator-python/

James Holmes
  • 394
  • 2
  • 5