+ 1
1)Why false ? 2) Why true?
1) Becouse it is list? x = [4,5] y = [4,5] print(x is y) //False 2) Or tuple? x = 4,5 y = 4,5 print(x is y) //True
3 Respostas
+ 5
Since lists are mutable, they don't refer to same object.. That's why it returns "False" where as, it is quite opposite in case of tuples(since they're immutable). So, it returns "True".
Let's say,
X and Y both are lists that are referring to same object. In this case, if you try to change the elements of X, then the effect will be shown on Y too... That's the reason why lists refer to different objects though they are equal.
+ 2
Thanks bro, I got answer.
1)Why false ? 2) Why true?
1)
Becouse it is list?
x = [4,5] //x's id 547927067776
y = [4,5] //y's id 547925724992
print(x is y) //False
2)
Or tuple?
x = 4,5 //x's id 515985706112
y = 4,5 //y's id 515985706112
print(x is y) //True
0
Mirielle yes