PYTHON- how are the two ELSE interfering with the two IF -
def completar_tablero (cursor, tablero, barco, sentido):     tupla, radio=cursor     x, y=tupla     print tupla     in range(0, 10):         if x>203+33*i , x<233+33*i:             print             p in range(0, 10):                 if y>53+33*p , y<53+33*p+30:                     print p                     casillas=(i, p)                     print casillas                 else:                     casillas=(-1, -1)            else:             casillas=(-1, -1)                print casillas      return casillas   this function receives coordinates input, , supposed return column , row, areas defined cycle.  issue function returns (-1, -1) tuple. used prints trying pinpoint problem, , noticed after second for, 'casillas' variable correctly defines, replaced 1 in first else. can tell me why happening?
as pointed @duffymo assumptions wrong in point values (among many other) give expected (?) results, ie. not returning (-1,-1):
x   y   : returns 529 366 : (9, 9) 529 367 : (9, 9) 529 368 : (9, 9) 529 369 : (9, 9) 529 370 : (9, 9) 529 371 : (9, 9) 529 372 : (9, 9)   you can test code (i've simplified function removing not used variables):
def completar_tablero (x,y):     in range(0, 10):         if x>203+33*i , x<233+33*i:             p in range(0, 10):                 if y>53+33*p , y<53+33*p+30:                     casillas=(i, p)                 else:                     casillas=(-1, -1)            else:             casillas=(-1, -1)                return casillas  x in range(0,1000):     y in range(0,1000):         z = completar_tablero (x,y)         if z[0]!=-1 , z[1]!=-1:             print x,y,":",z      
Comments
Post a Comment