Hey guys, i have been working on this for a while and global doesnt seem to be doing anything; help?
Row1 = [" "," "," "]
Row2 = [" "," "," "]
Row3 = [" "," "," "]
Grid = [Row1,Row2,Row3]
x = False
def NAC():
def check():
#only using this for testing
if Grid[0][0] == 'X' and Grid[0][1] == 'X' and Grid[0][2] == 'X':
print("player 1 wins!")
global x
x = True
#Only Using This for testing
elif Grid[1][0] == 'X' and Grid[1][1] == 'X' and Grid[1][2] == 'X':
print("player 1 wins!")
x = True
elif Grid[2][0] == 'X' and Grid[2][1] == 'X' and Grid[2][2] == 'X':
print("player 1 wins!")
x = True
elif Grid[0][0] == 'X' and Grid[1][0] == 'X' and Grid[2][0] == 'X':
print("player 1 wins!")
x = True
elif Grid[0][1] == 'X' and Grid[1][1] == 'X' and Grid[2][1] == 'X':
print("player 1 wins!")
x = True
elif Grid[0][2] == 'X' and Grid[1][2] == 'X' and Grid[2][2] == 'X':
print("player 1 wins!")
x = True
elif Grid[0][0] == 'X' and Grid[1][1] == 'X' and Grid[2][2] == 'X':
print("player 1 wins!")
x = True
elif Grid[0][2] == 'X' and Grid[1][1] == 'X' and Grid[0][1] == 'X':
print("player 1 wins!")
x = True
if Grid[0][0] == 'O' and Grid[0][1] == 'O' and Grid[0][2] == 'O':
print("player 2 wins!")
x = True
elif Grid[1][0] == 'O' and Grid[1][1] == 'O' and Grid[1][2] == 'O':
print("player 2 wins!")
x= True
elif Grid[2][0] == 'O' and Grid[2][1] == 'O' and Grid[2][2] == 'O':
print("player 2 wins!")
x = True
elif Grid[0][0] == 'O' and Grid[1][0] == 'O' and Grid[2][0] == 'O':
print("player 2 wins!")
x = True
elif Grid[0][1] == 'O' and Grid[1][1] == 'O' and Grid[2][1] == 'O':
print("player 2 wins!")
x = True
elif Grid[0][2] == 'O' and Grid[1][2] == 'O' and Grid[2][2] == 'O':
print("player 2 wins!")
x = True
elif Grid[0][0] == 'O' and Grid[1][1] == 'O' and Grid[2][2] == 'O':
print("player 2 wins!")
x = True
elif Grid[0][2] == 'O' and Grid[1][1] == 'O' and Grid[0][1] == 'O':
print("player 2 wins!")
x = True
DisplayGrid()
while x == False:
YourGo = input ("Your go\n Enter Number - ")
#Testing...
print(x)
#Testing...
if YourGo == '7':
Grid[0][0] = 'X'
DisplayGrid()
check()
elif YourGo == '8':
Grid[0][1] = 'X' #Player one's turn
DisplayGrid()
check()
elif YourGo == '9':
Grid[0][2] = 'X'
DisplayGrid()
check()
elif YourGo == '4':
Grid[1][0] = 'X'
DisplayGrid()
check()
elif YourGo == '5':
Grid[1][1] = 'X'
DisplayGrid()
check()
elif YourGo == '6':
Grid[1][2] = 'X'
DisplayGrid()
check()
elif YourGo == '1':
Grid[2][0] = 'X'
DisplayGrid()
check()
elif YourGo == '2':
Grid[2][1] = 'X'
DisplayGrid()
check()
elif YourGo == '3':
Grid[2][2] = 'X'
DisplayGrid()
check()
YourGo2 = input("Play 2's turn\nEnter number - ")
if YourGo2 == '7':
Grid[0][0] = 'O'
DisplayGrid()
check()
elif YourGo2 == '8': #player Two's turn
Grid[0][1] = 'O'
DisplayGrid()
check()
elif YourGo2 == '9':
Grid[0][2] = 'O'
DisplayGrid()
check()
elif YourGo2 == '4':
Grid[1][0] = 'O'
DisplayGrid()
check()
elif YourGo2 == '5':
Grid[1][1] = 'O'
DisplayGrid()
check()
elif YourGo2 == '6':
Grid[1][2] = 'O'
DisplayGrid()
check()
elif YourGo2 == '1':
Grid[2][0] = 'O'
DisplayGrid()
check()
elif YourGo2 == '2':
Grid[2][1] = 'O'
DisplayGrid()
check()
elif YourGo2 == '3':
Grid[2][2] = 'O'
DisplayGrid()
check()
def DisplayGrid():
print(" -----------")
DisplayRow(Grid[0][0],Grid[0][1],Grid[0][2])
print(" -----------")
DisplayRow(Grid[1][0],Grid[1][1],Grid[1][2])
print(" -----------")
DisplayRow(Grid[2][0],Grid[2][1],Grid[2][2])
print(" -----------")
def DisplayRow (a,b,c):
print(" | ",end="")
print(a,end="")
print(" | ",end="")
print(b,end="")
print(" | ",end="")
print(c,end="")
print(" |")
NAC()