Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Board = [0,1,2,
- 3,4,5,
- 6,7,8]
- def Tic_Tac_Toe():
- print(Board[0],Board[1],Board[2])
- print(Board[3],Board[4],Board[5])
- print(Board[6],Board[7],Board[8])
- print()
- def Play_1():
- Location = int(input('Player One Choose a Number :'))
- if Board[Location]!='X'and Board[Location]!='O':
- Board[Location]='X'
- else:
- print('Already Taken make another Choice')
- def Play_2():
- Location= int(input('Player Two Choose a Number :'))
- if Board[Location]!='O' and Board[Location]!='X':
- Board[Location]='O'
- else:
- print('Already Taken make another Choice ')
- def Check_Winner(X_or_O):
- if Board[0]==X_or_O and Board[1]==X_or_O and Board[2]==X_or_O:
- return True
- if Board[3]==X_or_O and Board[4]==X_or_O and Board[5]==X_or_O:
- return True
- if Board[6]==X_or_O and Board[7]==X_or_O and Board[8]==X_or_O:
- return True
- if Board[0]==X_or_O and Board[3]==X_or_O and Board[6]==X_or_O:
- return True
- if Board[1]==X_or_O and Board[4]==X_or_O and Board[7]==X_or_O:
- return True
- if Board[2]==X_or_O and Board[5]==X_or_O and Board[8]==X_or_O:
- return True
- if Board[0]==X_or_O and Board[4]==X_or_O and Board[8]==X_or_O:
- return True
- if Board[2]==X_or_O and Board[4]==X_or_O and Board[6]==X_or_O:
- return True
- while True:
- Play_1()
- Tic_Tac_Toe()
- if Check_Winner('X')==True:
- print('Player One Wins')
- break
- Play_2()
- Tic_Tac_Toe()
- if Check_Winner('O')==True:
- print('Player Two Wins')
- break
Advertisement
Add Comment
Please, Sign In to add comment