print("my_list:")for i, sub_list in enumerate(my_list):print("\t[{}]: {}".format(i, id(sub_list)))for j, elem in enumerate(sub_list):print("\t\t[{}]: {}".format(j, id(elem)))
aout:[[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]#Displaying the list
a.remove(a[0])out:[[1, 1, 1, 1], [1, 1, 1, 1]]# Removed the first element of the list in which you want altered number
a.append([5,1,1,1])out:[[1, 1, 1, 1], [1, 1, 1, 1], [5, 1, 1, 1]]# append the element in the list but the appended element as you can see is appended in last but you want that in starting
a.reverse()out:[[5, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]#So at last reverse the whole list to get the desired list
>>> my_list = [1]*4>>> my_list[1, 1, 1, 1]
>>> id(my_list[0])4522139440>>> id(my_list[1]) # Same as my_list[0]4522139440
>>> my_list[1] = 42 # Since my_list[1] is immutable, this operation overwrites my_list[1] with a new object changing its id.>>> my_list[1, 42, 1, 1]
>>> id(my_list[0])4522139440>>> id(my_list[1]) # id changed4522140752>>> id(my_list[2]) # id still same as my_list[0], still referring to value `1`.4522139440
import copy
def list_ndim(dim, el=None, init=None):if init is None:init = el
if len(dim)> 1:return list_ndim(dim[0:-1], None, [copy.copy(init) for x in range(dim[-1])])
return [copy.deepcopy(init) for x in range(dim[0])]