From 2be93d9f4695ad486524c5c332da6964f8ff82d5 Mon Sep 17 00:00:00 2001 From: prathamjn26 <52950832+prathamjn26@users.noreply.github.com> Date: Wed, 16 Oct 2019 15:02:06 +0530 Subject: [PATCH] Update Tic_tac_toe.py --- Python/Tic_tac_toe.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Python/Tic_tac_toe.py b/Python/Tic_tac_toe.py index 36edeae..4d2aa85 100644 --- a/Python/Tic_tac_toe.py +++ b/Python/Tic_tac_toe.py @@ -1,3 +1,4 @@ +import random def tic_tac_toe(): p=["1","2","3","4","5","6","7","8","9"] P1=None @@ -20,7 +21,13 @@ def pattern(): p1='O' print("Player1:You chose %c\n"%p1) print("Player2:You chose %c\n"%p2) - print("Player1:You should start the game\n\n") + def tose(): + choice=random.randint(0,1) + if choice==0: + print("Player1:You should start the game\n\n") + else: + print("Player2:You should start the game\n\n") + turn=tose() def player_1(): while(1): print("Player1:Place the position of %c\n"%p1) @@ -43,6 +50,10 @@ def player_2(): else: print("Player1:You chose a wrong cell\n") continue + if turn==0: + player_1() + else: + player_2() def game_win(): c=0 t=0