Question by
berto5656 · Jul 20, 2018 at 03:34 AM ·
programmingpython
how can i change game to false when the conditions are met in the winner() function?
how can i change game to false when the conditions are met in the winner() function?
import random
board = ["0","1","2","3","4","5","6","7","8"]
def drawBoard():
print(board[6], "|", board[7], "|", board[8])
print("_________")
print(board[3], "|", board[4], "|", board[5])
print("_________")
print(board[0], "|", board[1], "|", board[2])
def check_player_o():
player_o = random.randrange(0,9)
if board[player_o] != "x" and board[player_o] != "o":
board[player_o] = "o"
else:
check_player_o()
def winner():
if board[0] and board[1] and board[2] == "x":
print ("Player X is the winner")
game = False
drawBoard()
game = True
while game:
player_x = int(input("Enter where you want to place (0-8)"))
if board[player_x] != "x" and board[player_x] != "o":
board[player_x] = "x"
check_player_o()
drawBoard()
winner()
print(game)
else:
print("That Place is Already Occupied")
Comment
Your answer
Follow this Question
Related Questions
Why does RotateTowards rotate in an "orbit" rather than on the spot? Help me understand! 0 Answers
Best loop for counting down a variable after an action 0 Answers
Help to Add some Sort and Binary Search in the code. 1 Answer
How to make a Ragdoll move? 0 Answers
Index out of range exeption error help 0 Answers