I have a list called quan = [0, 0 ,0, 0]. I'm asking the user to input integers between 0 to 3 and storing them in another list called items. eg: items = [0, 1, 1, 2, 2, 2].
For each int in items, I want to increment the corresponding position in quan, i.e., quan should become [1, 2, 3, 0] in this case.
for i in items:
quan[items[i]] += 1
so far all I've ended up with an EoL error. A nudge in the right direction would be appreciated. Thanks.
quan[i] += 1.icontains the element, not the index so you can access it directly usingquan[i].