class game:
gamestillgoing=True
if gamestillgoing:
def __init__(self, board, turn):
self.board = ["#", "-", "-", "-",
"-", "-", "-",
"-", "-", "-"]
self.turn = input("Choose your turn X or O?\n")
print("Player {} goes first!".format(turn))
def displayboard(self):
print(self.board[1] + "|" + self.board[2] + "|" + self.board[3])
print(self.board[4] + "|" + self.board[5] + "|" + self.board[6])
print(self.board[7] + "|" + self.board[8] + "|" + self.board[9])
game.displayboard(self)
def choosepositionX(self):
position = int(input("Choose the position from 1-9\n"))
position = int(position)
if self.turn == "X":
self.board[position] = "X"
game.displayboard(self)
else:
while not self.turn == "X":
print("Choose the valid input.")
def choosepositonO(self):
position = int(input("Choose the position from 1-9\n"))
position = int(position)
if self.turn == "O":
self.board[position] = "O"
game.displayboard(self)
else:
while not self.turn == "O":
print("Choose the valid input.")
def checkwinrow(self):
row1 = self.board[1] == self.board[2] == self.board[3]
row2 = self.board[4] == self.board[5] == self.board[6]
row3 = self.board[7] == self.board[8] == self.board[9]
if row1 or row2 or row3 == "X":
print("Player X has won!\n ")
gamestillgoing = False
elif row1 or row2 or row3 == "O":
print("Player O has won!\n")
gamestillgoing = False
else:
gamestillgoing = True
def checkwincolumn(self):
column1 = self.board[1] == self.board[4] == self.board[7]
column2 = self.board[2] == self.board[5] == self.board[8]
column3 = self.board[3] == self.board[6] == self.board[9]
if column1 or column2 or column3 == "X":
print("Player X has won!\n")
gamestillgoing = False
elif column1 or column2 or column3 == "O":
print("Player O has won!\n")
gamestillgoing = False
else:
gamestillgoing = True
def checkwindiagonal(self):
diagonal1 = self.board[1] == self.board[5] == self.board[9]
diagonal2 = self.board[3] == self.board[5] == self.board[7]
if diagonal1 or diagonal2 == "X":
print("Player X has won!\n")
gamestillgoing = False
elif diagonal1 or diagonal2 == "O":
print("Player O has win!\n")
gamestillgoing = False
else:
gamestillgoing = True
def checktie(self):
row1 = self.board[1] == self.board[2] == self.board[3]
row2 = self.board[4] == self.board[5] == self.board[6]
row3 = self.board[7] == self.board[8] == self.board[9]
column1 = self.board[1] == self.board[4] == self.board[7]
column2 = self.board[2] == self.board[5] == self.board[8]
column3 = self.board[3] == self.board[6] == self.board[9]
diagonal1 = self.board[1] == self.board[5] == self.board[9]
diagonal2 = self.board[3] == self.board[5] == self.board[7]
if row1 == row2 == row3 or column1 == column2 == column3 or diagonal1 == diagonal2 != "X" or "O":
print("The game is Tie!")
gamestillgoing = False
else:
gamestillgoing = True
def playerturn(self):
if self.turn == "X":
game.choosepositionX(self)
elif self.turn == "O":
game.choosepositonO(self)
else:
"Choose the valid Input!\n"
game.playerturn(self)
else:
gamestillgoing=False
Start=game()
Start()
When I try to run this game its saying that there is an error in the last two lines. Can anyone help me to solve this problem? I just need the solution for the errors in the last two lines (i.e Start=game() Start()) The main problem is in calling the class.