我在python3中有问题,因此在这里您可以看到一个函数,因此我试图查看行或列中是否存在彼此相等的数字,但是 当我回想函数时,如果不遵守函数中的条件,函数也会为我提供值。
def check(v):
for i in range(0,9,3):
if(v[i]==v[i+1]==v[i+2] and v[i]==0):
return 10
if(v[i]==v[i+1] and v[i]==v[i+2] and v[i]==1):
return -10
for i in range(0,3):
if(v[i]==v[i+3]==v[i+6] and v[i]==0):
return 10
if(v[i]==v[i+3]==v[i+6] and v[i]==1):
return -10
if(v[0]==v[4]==v[8] and v[0]==0):
return 10
if(v[0]==v[4]==v[8] and v[0]==1):
return -10
if(v[2]==v[4]==v[6] and v[0]==0):
return 10
if(v[2]==v[4]==v[6] and v[0]==1):
return -10
return 15
v = [1,1,"_","_","_","_","_","_","_"]
a =check(v)
print(a)