MCPcopy Create free account
hub / github.com/geekcomputers/Python / enter_number

Function enter_number

tik_tak.py:25–74  ·  view source on GitHub ↗
(p1_sign, p2_sign)

Source from the content-addressed store, hash-verified

23
24
25def enter_number(p1_sign, p2_sign):
26 global switch
27 global j
28 k = 9
29 while j:
30 if k == 0:
31 break
32
33 if switch == "p1":
34 p1_input = int(input("\nplayer 1 :- "))
35 if p1_input <= 0:
36 print("chose number from given board")
37 else:
38 for e in range(1, 10):
39 if board[e] == p1_input:
40 board[e] = p1_sign
41 print_board()
42 c = checkwin()
43 if c == 1:
44 print("\n\n Congratulation ! player 1 win ")
45 return
46
47 switch = "p2"
48 j -= 1
49 k -= 1
50 if k == 0:
51 print("\n\nGame is over")
52 break
53
54 if k == 0:
55 break
56
57 if switch == "p2":
58 p2_input = int(input("\nplayer 2 :- "))
59 if p2_input <= 0:
60 print("chose number from given board")
61 # return
62 else:
63 for e in range(1, 10):
64 if board[e] == p2_input:
65 board[e] = p2_sign
66 print_board()
67 w = checkwin()
68 if w == 1:
69 print("\n\n Congratulation ! player 2 win")
70 return
71
72 switch = "p1"
73 j -= 1
74 k -= 1
75
76
77def checkwin():

Callers 1

playFunction · 0.85

Calls 2

checkwinFunction · 0.85
print_boardFunction · 0.70

Tested by

no test coverage detected