I want to add an element in a nested list
my_list = [[0]]*10
x = int(input())
my_list[x].append(x)
print(my_list)
The output I am expecting if x=1
:
[[0], [0, 1], [0], [0], [0], [0], [0], [0], [0], [0]]
But this is what I am getting:
[[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]]