def vencedor_linha(t):
if (t[0]=='X' and t[1] and t[2]=='X') or (t[3]=='X' and t[4]=='X' and t[5]=='X') or (t[6]=='X' and t[7]=='X' and t[8]=='X'):
print("'X'")
return True
elif (t[0]=='O' and t[1] and t[2]=='O') or (t[3]=='O' and t[4]=='O' and t[5]=='O') or (t[6]=='O' and t[7]=='O' and t[8]=='O'):
print("'O'")
return True
else:
return False
def vencedor_coluna(t):
if (t[0]=='X' and t[3] and t[6]=='X') or (t[1]=='X' and t[4]=='X' and t[7]=='X') or (t[2]=='X' and t[5]=='X' and t[8]=='X'):
print("'X'")
return True
elif (t[0]=='O' and t[3] and t[6]=='O') or (t[1]=='X' and t[4]=='O' and t[7]=='O') or (t[2]=='O' and t[5]=='O' and t[8]=='X'):
print("'O'")
return True
else:
return False
def vencedor_diagonal(t):
if (t[0]=='X' and t[4] and t[8]=='X') or (t[6]=='X' and t[4]=='X' and t[2]=='X'):
print("'X'")
return True
elif (t[0]=='O' and t[4] and t[8]=='O') or (t[6]=='X' and t[4]=='O' and t[2]=='O'):
print("'O'")
return True
else:
return False
def determina_vencedor(t):
if vencedor_coluna(t):
return vencedor_coluna
elif vencedor_linha(t):
return vencedor_linha
elif vencedor_diagonal(t):
return vencedor_diagonal
else:
return False
したがって、使用する場合:
test1=('O',' ',' ',' ','O',' ',' ',' ','O')
と
test2=(' ',' ',' ','X',' ',' ',' ',' ',' ')
それは私を返すはずです、determina_vencedor(test1)
->'O'
そしてdetermina_vencedor(test2)
->False
問題は、test2でtest2
私に与えられることです。"'O', function vencedor_diagonal at 0x0000000002C29A48"
どうしたの?!私が理解するのを手伝ってください!