== Vs is in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

== Vs is in Python

What will the output of the following code be? (Treat the comma in the multiple choice answer as a newline.) a = [1, 2, 3] b = a c = [1, 2, 3] print(a == b) print(a is b) print(a == c) print(a is c) .

6th Jun 2018, 2:18 AM
Lakshman Patel
Lakshman Patel - avatar
3 Answers
+ 7
a = [1, 2, 3] b = a c = [1, 2, 3] print(a == b) print(a is b) print(a == c) print(a is c) print("a", a, id(a)) print("b", b, id(b)) print("c", c, id(c))
6th Jun 2018, 2:32 AM
Paul
Paul - avatar
+ 4
I have mentioned it in this with an example. Refer point 6. https://www.sololearn.com/discuss/1187881/?ref=app
6th Jun 2018, 6:41 PM
Mitali
Mitali - avatar
+ 3
True #b is referring to a. So have same content True #b is referring to a. So b is just internal copy of a True #both a and c have same content False #a and c are not same. Only their content are same. In python, we call they have different signatures
6th Jun 2018, 2:28 AM
Gopal Gautam
Gopal Gautam - avatar