I'm just starting to learn Python. I'm stuck upon a problem. Kindly clear my doubt.
a='abc'
b='abc'
a==b #When I run this O/P is True. But, in C/C++ or Java it turns out to be False because the variables(a & b) refer to different memories.
a is b #When I run this O/P is True. Ok understood , but.....
BUT WHEN
a=[1,2,3]
b=[1,2,3]
a==b #The out put is True
a is b #THe output is False
What is the reason for the two different outputs in the case of strings and lists?
I tried it for A=1 and B=1. then A is B yields True. and for A=257 , B=257 yields False. Thanks – Praful Bagai Jun 18 '13 at 14:32