I'm making a connect4 game for a class and im running into an error with my play function that I'm having difficulties figuring out.
def play(grid,column,checker):
counter = 0
for x in grid[0]:
counter += 1
print(counter)
if counter > column-1 :
for row in reversed(grid):
if row[column-1] == "empty":
row[column-1] = checker
print(True)
return True,grid,checker
else:
print(False)
return False , grid , checker
The problem occurs at line 9 (if row[column-1] == "empty") and I keep getting typeError 'int' opject is not subscriptable. grid is a global variable returned from a different function. Thanks for any help!
The problem here is actually in the different function
gridis returned from. You must have made some mistake there, which causes that different function return something of the form[1, 6, 3, 8, 3], whereas yourplayfunction assumes something in the form of[[1, 5, 6, 2, 10], [1, 5, 6, 2, 10], [1, 5, 6, 2, 10], [1, 5, 6, 2, 10]].