Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x1=1
- x2=2
- x3=3
- x4=4
- x5=5
- x6=6
- x7=7
- x8=8
- x9=9
- x="X"
- o="O"
- a=0
- oturn="O's turn"
- xturn="X's turn"
- print(" press any letter to end the program")
- print(" ")
- print(" ")
- print(" ")
- print(" press a number from the grid to play")
- print(" ")
- print(" ")
- print(" ")
- while a < 9:
- print(x1,"|",x2,"|",x3," ",oturn)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- y = int(input())
- if y == x1:x1=o
- if y==x2:x2=o
- if y==x3:x3=o
- if y==x4:x4=o
- if y==x5:x5=o
- if y==x6:x6=o
- if y==x7:x7=o
- if y==x8:x8=o
- if y==x9:x9=o
- if x1==x2 and x2 ==x3 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x3)
- a=9
- elif x4==x5 and x5==x6 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x6)
- a=9
- elif x7==x8 and x8 ==x9 :
- print(x1,"|",x2,"|",x3," ",xturn)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x9)
- a=9
- elif x1==x4 and x4 ==x7 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x7)
- a=9
- elif x2==x5 and x5 ==x8 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x8)
- a=9
- elif x3==x6 and x6==x9 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x9)
- a=9
- elif x3==x5 and x5 ==x7 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x7)
- a=9
- elif x1==x5 and x5 ==x9 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x9)
- a=9
- else :
- a=a+1
- if a<9:
- print(x1,"|",x2,"|",x3," ",xturn)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- c = int(input())
- if c == x1:x1=x
- if c==x2:x2=x
- if c==x3:x3=x
- if c==x4:x4=x
- if c==x5:x5=x
- if c==x6:x6=x
- if c==x7:x7=x
- if c==x8:x8=x
- if c==x9:x9=x
- if x1==x2 and x2 ==x3 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x3)
- a=9
- elif x4==x5 and x5==x6 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x6)
- a=9
- elif x7==x8 and x8 ==x9 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x9)
- a=9
- elif x1==x4 and x4 ==x7 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x7)
- a=9
- elif x2==x5 and x5 ==x8 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x8)
- a=9
- elif x3==x6 and x6==x9 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x9)
- a=9
- elif x3==x5 and x5 ==x7 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x7)
- a=9
- elif x1==x5 and x5 ==x9 :
- print(x1,"|",x2,"|",x3)
- print("---------")
- print(x4,"|",x5,"|",x6)
- print("---------")
- print(x7,"|",x8,"|",x9)
- print("gg player",x9)
- a=9
- else :
- a=a+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement