In python, my current code works to a certain point. I have another function called check_X_win_status()
which does the same thing that the one below does, except it checks for 1, instead of -1. Anyone have any ideas as to how to make this more compact? Also, I sometimes get an error in which the code prints "win" even if the game_status = -1, 1,-1, 0, 0, 0, 0, 0, 0
game_status = [-1,-1,-1,0,0,0,0,0,0]
def check_O_win_status():
if game_status[0] and game_status[1] and game_status[2] == -1:
print("O wins!")
if game_status[3] and game_status[4] and game_status[5] == -1:
print("O wins!")
if game_status[6] and game_status[7] and game_status[8] == -1:
print("O wins!")
if game_status[0] and game_status[3] and game_status[6] == -1:
print("O wins!")
if game_status[1] and game_status[4] and game_status[7] == -1:
print("O wins!")
if game_status[2] and game_status[5] and game_status[8] == -1:
print("O wins!")
if game_status[0] and game_status[4] and game_status[8] == -1:
print("O wins!")
if game_status[2] and game_status[4] and game_status[6] == -1:
print("O wins!")