From ae638ba9cb8a86e51d5686a4c8f1771b79d4d708 Mon Sep 17 00:00:00 2001 From: Jawwad Zafar Date: Wed, 2 Jun 2021 18:54:31 +0530 Subject: [PATCH] refactor --- game.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/game.py b/game.py index aba6de7..be52e94 100644 --- a/game.py +++ b/game.py @@ -18,12 +18,9 @@ def display_board(self): def turn(self): print(self.current_player + "'s turn.") - # TODO: improve to show only available turns - # TODO: handle exception for non int numbers position = input("Choose a position from 1 to 9 ") valid = False while not valid: - # TODO: use range instead of list while position not in ["1", "2", "3", "4", "5", "6", "7", "8", "9"]: position = input("Incorrect. Choose a position from 1 to 9 again ") @@ -118,7 +115,6 @@ def check_game_status(self): return def run(self): - print('Welcome to Terminal Tic Tac Toe') self.display_board() while self.game_still_going: @@ -127,12 +123,11 @@ def run(self): self.check_game_status() #End of the game - if self.winner == "X" or self.winner == "O": + if self.winner != None: print(self.winner + " won.") - elif self.winner == None: + else: print("Tie. ") if __name__ == "__main__": - print('Creating game object...') game = Game() game.run() \ No newline at end of file