Sometimes this code works just fine and runs through, but other times it throws the int object not callable error. I am not real sure as to why it is doing so.
for ship in ships:vert_or_horz = randint(0,100) % 2for size in range(ship.size):if size == 0:ship.location.append((random_row(board),random_col(board)))else:# This is the horizontal placingif vert_or_horz != 0 and ship.size > 1:ship.location.append((ship.location[0][0], \ship.location[0][1] + size))while(ship.location[size][1] > len(board[0])) or \(ship.location[size][1] < 0):if ship.location[size][1] > len(board[0]):ship.location[size][1]((ship.location[0][0], \ship.location[0][1] - size))if ship.location[size][1] < 0:ship.location[size][1]((ship.location[0][0], \ship.location[0][1] + size))# This is the vertical placingif vert_or_horz == 0 and ship.size > 1:ship.location.append((ship.location[0][0] + size, \ship.location[0][1]))while(ship.location[size][1] > len(board[0])) or \(ship.location[size][1] < 0):if ship.location[size][1] > len(board[0]):ship.location[size][1] \((ship.location[0][0] - size, \ship.location[0][1]))if ship.location[size][1] < 0:ship.location[size][1] \((ship.location[0][0] + size, \ship.location[0][1]))
Here is the traceback:
Traceback (most recent call last):File "python", line 217, in <module>File "python", line 124, in create_med_gameship.location[size][1]((ship.location[0][0], \
TypeError: 'int' object is not callable