What is different about these two methods of initializing that changes the answer so drastically?
queries = ["1 0 5",
"1 1 7",
"1 0 3",
"2 1 0",
"2 1 1"];
#Option 1:
queries_num = [[]]*len(queries);
#Option 2:
queries_num = [[],[],[],[],[]];
for x in queries:
for y in x:
if y in ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]:
queries_num[queries.index(x)].append(int(y));
print(queries_num)
Option 1 prints:
[[1, 0, 5, 1, 1, 7, 1, 0, 3, 2, 1, 0, 2, 1, 1], [1, 0, 5, 1, 1, 7, 1, 0, 3, 2, 1, 0, 2, 1, 1], [1, 0, 5, 1, 1, 7, 1, 0, 3, 2, 1, 0, 2, 1, 1], [1, 0, 5, 1, 1, 7, 1, 0, 3, 2, 1, 0, 2, 1, 1], [1, 0, 5, 1, 1, 7, 1, 0, 3, 2, 1, 0, 2, 1, 1]]
Option 2 prints:
[[1, 0, 5], [1, 1, 7], [1, 0, 3], [2, 1, 0], [2, 1, 1]]
I'd like to use Option 1 but get the answer that Option 2 gives.