Question
Using this python coding: If a game ends in a draw have the game print(Draw) then ask to either start over or end the game
Using this python coding: If a game ends in a draw have the game print("Draw") then ask to either start over or end the game
print("TIC TAC TOE GAME")
while not wn : boarddesign()#printing the board
if user1 :#asking fot the player 1 input print(" X for Player1 O for Player2") print(" Enter the grid value for your move") print(" Player 1:") else : #asking for the player 2 input print(" X for Player1 O for Player2") print(" Enter the grid value for your move") print(" Player 2:") if user1 : ch[inp - 1] = 'X' else : ch[inp - 1] = 'O' user1 = not user1 for x in range (0, 3) : y = x * 3 if (ch[y] == ch[(y + 1)] and ch[y] == ch[(y + 2)]) : wn = True boarddesign() if (ch[x] == ch[(x + 3)] and ch[x] == ch[(x + 6)]) : wn = True boarddesign() if((ch[0] == ch[4] and ch[0] == ch[8]) or (ch[2] == ch[4] and ch[4] == ch[6])) : wn = True boarddesign() #displaying the winner print ("Player " + str(int(user1 + 1)) + " is the winner! ")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started