QuestionQ159

VerifiedData Collections – Tuples, Dictionaries, Lists, and Strings

What is the expected output from the following code?

Question Image

Explanation

Separate list literals create different objects, so the identity comparison using is is False, while the value comparison using == is True because their contents match. Assigning list2 to list1 makes both variables refer to the same object, so both later comparisons evaluate to True.

Community Discussion

No comments yet. Be the first to start the discussion!