Iterating over the elements of two 2D lists in python and printing the difference -


i have 2 2d lists:

list1 = [[]] list2 = [[]] 

and in loop iterate on bunch of registers , write operations , readback operation , populated lists.

list1.append([regname,writevalue]) list2.append([regname,readvalue]) 

now want compare these 2 lists make sure readback values registers same ones wrote. doing that:

for (x,i),(y,j) in itertools.izip(list1,list2):     if [x][i] != [y][j]:         print >> myfile, 'mismatch: reg_name = %s, expected_value =0x%x, actual_value =0x%x' % (x,i,j) 

this of course wrong , gives me error saying valueerror:need more 0 values unpack.

how compare write , read values same corresponding register name in 2 lists , print mismatches?

1: way start list1 , list2 empty list causing error!

2: not problem!

when fix list assignment code , run it, following error:

traceback (most recent call last):   file "<stdin>", line 2, in <module> indexerror: list index out of range 

that because in for loop, making variables x i y j elements in list , trying index them, , can't that. not sure if syntax use okay...the following want:

for x,y in zip(list1,list2):     if x not y:         # want here 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -