I have a lists of list, and I would like to append data to each sublist independently. When I append to one, it seems like ALL of the sublists are getting the same data appended. Here is my code:
Code:
parent = [[]] * 2
data = [1]*4
parent[0].append(data)
print "sublist 0:", parent[0]
print "sublist 1:", parent[1]
Output:
sublist 0: [[1, 1, 1, 1]]
sublist 1: [[1, 1, 1, 1]]
Expected Output:
sublist 0: [[1, 1, 1, 1]]
sublist 1: []
What am I doing wrong or not understanding here?