Created
August 31, 2016 10:14
-
-
Save mohammedvaghjipurwala/9cdeb7ae6165de91b6acced63e166b4f to your computer and use it in GitHub Desktop.
Revisions
-
mohammedvaghjipurwala renamed this gist
Aug 31, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
mohammedvaghjipurwala created this gist
Aug 31, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ game = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] i = 1 #### Prints the list in matrix form def PrintMat(game): return ('\n'.join(str(i) for i in game)) #### to get the input from the user. def TicTacToeInput(game,i): if any(0 in s for s in game): if i % 2 != 0: Player = "X" else: Player = "O" print ("\nPlayer ",Player," Turn!!! \n") row = int(input("Enter the row (1-3): ")) - 1 col = int(input("Enter the column (1-3): ")) - 1 if game[row][col] == 0: game[row][col] = Player i += 1 print (PrintMat(game)) TicTacToeInput(game,i) else: print ("Invalid position please Try again") TicTacToeInput(game,i) if __name__ == "__main__": print ("Welcome to the Tic Tac Toe game !!!") TicTacToeInput(game,i)