I wanted to build a tic tac toe game but something is wrong with my win function
def check_if_gameover(d):
if d[1] and d[4] and d[7] == 'X' or 'O':
return True
elif d[1] and d[5] and d[9] == 'X' or 'O':
return True
elif d[1] and d[2] and d[3] == 'X' or 'O':
return True
elif d[7] and d[8] and d[9] == 'X' or 'O':
return True
elif d[4] and d[5] and d[6] == 'X' or 'O':
return True
elif d[9] and d[6] and d[3] == 'X' or 'O':
return True
elif d[8] and d[5] and d[2] == 'X' or 'O':
return True
elif d[7] and d[5] and d[3] == 'X' or 'O':
return True
else:
return False
the d stands for dictionary and i wanted to check for example the first statement if X or O is in d[1], d[4] and in d[7] at the same time but instead when there was one of them == to X or O it returned True. If you understand my question please reply. Thanks