What is meaning of the error and where is the mistake?
I got the TypeError: 'function' object is not subscriptable for the following line:
row = random.choice(get_the_valid_locations[-2])
here is the get_the_valid_locations function:
def get_the_valid_locations(board):
valid_locations = []
for col in range(COLS_OF_BOARD):
for row in range(ROWS_OF_BOARD):
if available_square(board, row, col):
valid_locations.extend([row, col])
return valid_locations
get_the_valid_locations[-2] is an int (I checked).
If you need more Code just ask for it the comments!
-2is supposed to be. Presumably you want element at index -2 from the list returned byget_the_valid_locations. However you need to call that function and pass argument forboard(2D list?). We don't know what object/variable you want to pass for board.COLS_OF_BOARDandROWS_OF_BOARDis coming from. Probably global variables?