Question 16
What will be the output of the code snippet below?
x = [1, 2, 3]
y = x[::-1]
print(x is y, x == y[::-1])
Slicing x[::-1] creates a new inverted list object y = [3, 2, 1]. x is y is False because they are distinct memory objects. x == y[::-1] is True because [3, 2, 1][::-1] equals [1, 2, 3].