TIC TAE TOE's problem(i am beginner)

tflchkl at gmail.com tflchkl at gmail.com
Sat Apr 15 07:31:27 EDT 2017


A=['1', ' ', '1']
B=['1', ' ', '2']
C=['1', ' ', '3']
D=['2', ' ', '1']
E=['2', ' ', '2']
F=['2', ' ', '3']
G=['3', ' ', '1']
H=['3', ' ', '2']
I=['3', ' ', '3']
N=int(9)
def my_func1():
    X=list(input())
    global N
    N=N-1
    if X==['1', ' ', '1']:
        A="X"
        my_func3()
        my_func2()
    if X==['1', ' ', '2']:
        B="X"
        
        my_func3()
        my_func2()       
    if X==['1', ' ', '3']:
        C="X"
        
        my_func3()
        my_func2()    
    if X==['2', ' ', '1']:
        D='X'
        
        my_func3()
        my_func2()   
    if X==['2', ' ', '2']:
        E="X"
        my_func3()
        my_func2()
    if X==['2', ' ', '3']:
        F='X'
        
        my_func3()
        my_func2()

    if X==['3', ' ', '1']:
        G='X'
        
        my_func3()
        my_func2()
    if X==['3', ' ', '2']:
        H='X'
        
        my_func3()
        my_func2()
    if X==['3', ' ', '3']:
        I='X'
        
        my_func3()
        my_func2()
def my_func2():
    Y=list(input())
    global N
    N=N-1
    if Y==['1', ' ', '1']:
        A="O"
        
        my_func3()
        my_func1()
    if Y==['1', ' ', '2']:
        B="O"
        
        my_func3()
        my_func1()       
    if Y==['1', ' ', '3']:
        C="O"
        
        my_func3()
        my_func1()    
    if Y==['2', ' ', '1']:
        D="O"
       
        my_func3()
        my_func1()   
    if Y==['2', ' ', '2']:
        E="O"
        
        my_func3()
        my_func1()
    if Y==['2', ' ', '3']:
        F="O"
        
        my_func3()
        my_func1()

    if Y==['3', ' ', '1']:
        G="O"
        
        my_func3()
        my_func1()
    if Y==['3', ' ', '2']:
        H="O"
        
        my_func3()
        my_func1()
    if Y==['3', ' ', '3']:
        I="O"
        
        my_func3()
        my_func1()

def my_func3():
    if A and B and C=="X":
        print("X win")
    elif D=="X" and E=="X" and F=="X":
        print("X win")
    elif G=="X" and H=="X" and I=="X":
        print("X win")
    elif A=="X" and D=="X" and G=="X":
        print("X win")
    elif B=="X" and E=="X" and H=="X":
        print("X win")
    elif C=="X" and F=="X" and I=="X":
        print("X win")
    elif A=="X" and E=="X" and I=="X":
        print("X win")
    elif A=="O" and B=="O" and C=="O":
        print("O win")
    elif D=="O" and E=="O" and F=="O":
        print("O win")
    elif G=="O" and H=="O" and I=="O":
        print("O win")
    elif A=="O" and D=="O" and G=="O":
        print("O win")
    elif B=="O" and E=="O" and H=="O":
        print("O win")
    elif C=="O" and F=="O" and I=="O":
        print("O win")
    elif A=="O" and E=="O" and I=="O":
        print("O win")
    elif N==0:
        print("DRAW")
print(A,B)
P=input("X/O:")
if P=="X":
    my_func1()
else:
    my_func2()



why cant function to print X or O win...


More information about the Python-list mailing list