I have an array that looks like the following: ["string", int , [] ] but when I try to increment the int Python gives me an error. (by the way I am new to python so this might be a simple question)
TypeError: 'int' object is not iterable
Here is my problematic part of the code:
for line in responseid_container:
if line[0] is log.id_resp_address:
ipFound = True
#--- this line is where I get an exception ---
responseid_container[1] += 1
responseid_container[2].append = log.id_resp_address
(example for responseid_container = ['54.192.11.194', 1, [0]])
I tried to look for an answer in many places, such as: here,here,here, here , and many more... I hope it is not a duplicated answer but I did try and find if it is :-)
Here is my full code of the class if needed
from reader import fullLog
class counters:
local_logs = []
arrange_by_response_id = []
def __init__(self , fulllog):
self.local_logs = fulllog
def arrangebyresonseid(self):
responseid_container = [[" " , 0 , []]]
ipFound = False
counter = 0
for log in self.local_logs.oopList:
for line in responseid_container:
if line[0] is log.id_resp_address:
ipFound = True
responseid_container[1] += 1
responseid_container[2].append = log.id_resp_address
if not ipFound:
ipFound = False
responseid_container.append([log.id_resp_address , 1 , [counter]])
counter += 1