1

I have the following code:

a = []
b = a

when I compile the following code I get this:

print(b is a) --> True
print(b is []) --> False

if b = a then shouldn't b is [] return True?

Nant
  • 569
  • 2
  • 10
  • 24

1 Answers1

5

try that:

    a = []
b = a


print(id(a))
print(id(b))
print(id([]))

And you will see that a and b refers to the same object, while next [] is a different one. Check if b to see if b is not empty list

snamef
  • 195
  • 1
  • 10