print((1, 2, 3) == [1, 2, 3])
Even though the tuple and list have the same elements, Python's == operator returns False when comparing different sequence types.
print((1, [2, 3]) == (1, [2, 3]))
Both tuples contain the same elements, including the same list inside. So the comparison returns True.
print((1, 2, 3) == [3, 2, 1])
The tuple and list have the same elements but in different order, so the comparison returns False.
a = [1, 2] b = (1, 2) print(a == b) a[0] = 3 print(a == b)
Initially, the list and tuple have the same elements, so a == b is False because they are different types. After changing the first element of the list, they still differ, so the comparison remains False.
Python's == operator for sequences first checks if lengths are equal, then compares elements pairwise recursively. The specific types (tuple or list) do not affect equality; only contents matter. Thus, True.
