-
Notifications
You must be signed in to change notification settings - Fork 0
/
app data.py
49 lines (43 loc) · 1.43 KB
/
app data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
print(' -------------')
print(' | * | * | * |')
print(' | * | * | * |')
print(' | * | * | * |')
print(' -------------')
p1=input('player1 choose x or o:')
if p1=='x':
p2='o'
else:
p2='x'
draw=1
mat=[['*','*','*'],
['*','*','*'],
['*','*','*']]
for step in range (9):
row=int(input('enter no of row:'))
column=int(input('enter no of column:'))
if(mat[row][column]=='x') or (mat[row][column]=='o'):
print('invalid')
row=int(input('enter row:'))
column=int(input('enter column:'))
if step%2==0:
mat[row][column]=p1
else:
mat[row][column]=p2
for row in range (3):
print(' -------------')
print(' |',mat[row][0],'|',mat[row][1],'|',mat[row][2],'|')
print(' -------------')
if step>=4:
for row in range(3):
if (mat[row][0]==mat[row][1]==mat[row][2]==p1)or (mat[0][row]==mat[1][row]==mat[2][row]==p1)or(mat[0][0]==mat[1][1]==mat[2][2]==p1)or(mat[0][2]==mat[1][1]==mat[2][0]==p1):
print('player1 is the winner xD')
draw=0
break
elif (mat[row][0]==mat[row][1]==mat[row][2]==p2)or (mat[0][row]==mat[1][row]==mat[2][row]==p2)or(mat[0][0]==mat[1][1]==mat[2][2]==p2)or(mat[0][2]==mat[1][1]==mat[2][0]==p2):
print('player2 is the winner xD')
draw=0
break
if draw==0:
break
if draw==1:
print('its a draw')