Advertisement
xdrasz

tictactoe grid

May 28th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. x1=1
  2. x2=2
  3. x3=3
  4. x4=4
  5. x5=5
  6. x6=6
  7. x7=7
  8. x8=8
  9. x9=9
  10. x="X"
  11. o="O"
  12. a=0
  13. print("press any letter to end the program")
  14. print(".")
  15. print(".")
  16. print(".")
  17. print("press a number from the grid to play")
  18. print(x1,"!",x2,"!",x3)
  19. print("---------")
  20. print(x4,"!",x5,"!",x6)
  21. print("---------")
  22. print(x7,"!",x8,"!",x9)
  23. while a < 9:
  24.     print("o move")
  25.     y = int(input())
  26.     if y == x1:x1=o
  27.     if y==x2:x2=o
  28.     if y==x3:x3=o
  29.     if y==x4:x4=o
  30.     if y==x5:x5=o
  31.     if y==x6:x6=o
  32.     if y==x7:x7=o
  33.     if y==x8:x8=o
  34.     if y==x9:x9=o
  35.     print(x1,"!",x2,"!",x3)
  36.     print("---------")
  37.     print(x4,"!",x5,"!",x6)
  38.     print("---------")
  39.     print(x7,"!",x8,"!",x9)
  40.     a=a+1
  41.     if a<9:
  42.         print("x  move")
  43.         c = int(input())
  44.         if c == x1:x1=x
  45.         if c==x2:x2=x
  46.         if c==x3:x3=x
  47.         if c==x4:x4=x
  48.         if c==x5:x5=x
  49.         if c==x6:x6=x
  50.         if c==x7:x7=x
  51.         if c==x8:x8=x
  52.         if c==x9:x9=x
  53.         print(x1,"!",x2,"!",x3)
  54.         print("---------")
  55.         print(x4,"!",x5,"!",x6)
  56.         print("---------")
  57.         print(x7,"!",x8,"!",x9)
  58.         a=a+1
  59. print("gg a celui qui a gagne")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement