I'm trying to keep track of something with 5 categories and 10 subcategories each. Each item is described with a 0 or a 1. I decided to make a list of lists in the following format:
[[0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0]...]
When trying to assign a value to only one of these sub-lists, the code assign it to all the sub-lists.
This is a snippet of the code:
categories=['a','b','c','d','e','f']
status=[]
zeros=[0,0,0,0,0,0,0,0,0,0]
for i in categories:
status.append(zeros)
print(status)
category=0
subcategory=1
status[category][subcategory] = 2
print(status)
result:
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
[[0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0, 0, 0]]
I want the program to only edit one list at a time but instead if edits all the subcategories. What am I doing wrong here?