I come from R and am trying to get a better grip on mutability. Below is code, the first two parts of which I think I understand (see comments). I do not understand the third part.
#1. Refering to same instance with two variable names
listOrig = [i for i in range(1001, 1011)]
listCopy = listOrig
listOrig[0]=999
listOrig == listCopy #Returns True, because both variable names actually refer
#to the same instance, ergo still containing the same values
listOrig[0] is listCopy[0] #Same instance 999, the id is also the same as a
#consequence
#2. Refering to same part of original list through slicing
listSlice = listOrig[0:5]
listOrig[0] is listSlice[0] #Returns True, analogous to above
a = 999
listOrig[0] == a #True because it's the same value or number
listOrig[0] is a #False because they are different instances with different IDs
#3. WHAT I DO NOT UNDERSTAND: changing the sliced copy does not affect the original list
listOrig
listSlice
listSlice[0] = 1001
listOrig[0] is listSlice[0] #Different number, thus also obviously different ID