python - Incrementing Counter in List - Int Objects not Iterable Error -


i looking increment 2 separate counters contained in list , having error 'int objects not iterable' returned error. how can increase integer stored in specified place?

dc_counter = 0  in range(15):     in range(2):         decision_counter[dc_counter].append([0])     dc_counter += 1  line_counter = 0  j in all_decisions:     if all_decisions[line_counter][4] == 1:         decision_counter[session_num][0] += 1      elif all_decisions[line_counter][4] == 2:         decision_counter[session_num][1] += 1      line_counter +=1  

your decision_counter 1 layer of lists deeper expected. sample:

[[[0], [1]], [[0], [1]], [[0], [1]], [[0], [1]]] 

what intended was:

[[0, 1], [0, 1], [0, 1], [0, 1]] 

to that, remove brackets append:

decision_counter[dc_counter].append(0)    # <-- append(0) instead of append([0]) 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -