Data types · 26 / 29 Exercise Medium

Spot the alias

Objective

The is operator checks identity (is it the same object?) and == checks equality (do they have the same value?). A copy is equal to the original, but it is not the same object.

Instructions

  • Write a program that creates a = [1, 2, 3], then b = a and c = list(a).
  • Show three lines: same or different depending on whether a is the same object as b; same or different depending on whether a is the same object as c; and equal or different depending on whether a has the same value as c.
Output
same
different
equal

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise