Code Explanation:
๐ธ 1. List Creation (a)
A list [1,2] is created
Stored at some memory location
Variable a points to that location
๐ธ 2. List Creation (b)
Another list [1,2] is created
This is a different object in memory
Variable b points to a new location
๐ธ 3. Equality Check (a == b)
== compares values inside objects
Both lists have same elements [1,2]
✅ Result → True
๐ธ 4. Identity Check (a is b)
is compares memory location (object identity)
a and b are different objects
❌ Result → False
๐ธ 5. Final Output
True False

0 Comments:
Post a Comment