Error i not defined in for loop using python -
i have 1 array 'barray' of size 'bsize' , 'carray' of size 'csize'. i
loop barray , j
loop carray.
i error not defined. want loops go 0 bsize - 2 in steps of 3, , 0 csize - 2 in single steps.
how should relate size , array loop?
bsize = 960 csize = 960 barray = bytearray(fi.read()) carray= bytearray(f1.read()) in range (bsize-2,i+3): j in range (csize-2,j+1):
in range (0, bsize - 2, 3): #possibly bsize - 1? j in range (csize - 2): # possibly csize - 1? #do thing
that loop through first 1 incrementing i
3 every time, , j
1.
look @ tutorial or these docs learn range
, it's useful!
i'm not sure if want go through bsize - 2 or it. if through, use size - 1 size - 2.
the reason you're getting error haven't defined i
you're using in step. can see, python's range
isn't lot of other languages' for
constructs. once used it, though, it's flexible , easy use.
some examples using simple range:
>>> in range(0, 14, 3): ... print ... 0 3 6 9 12 >>> in range(1, 5): ... print ... 1 2 3 4 >>> in range(5): ... print ... 0 1 2 3 4
Comments
Post a Comment