Advertisement
Kamend1

tic_tac_toe_kamen_dimitrov_python_fund

Oct 2nd, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. game = []
  2.  
  3. for i in range(3):
  4. game.append(list(int(x) for x in input().split()))
  5.  
  6. # first row
  7. if game[0][0] == game[0][1] and game[0][2]:
  8. if game[0][0] == 1:
  9. print("First player won")
  10. elif game[0][0] == 2:
  11. print("Second player won")
  12. else:
  13. pass
  14.  
  15. # second row
  16. elif game[1][0] == game[1][1] and game[1][2]:
  17. if game[1][0] == 1:
  18. print("First player won")
  19. elif game[1][0] == 2:
  20. print("Second player won")
  21. else:
  22. pass
  23.  
  24. # third row
  25. elif game[2][0] == game[2][1] and game[2][2]:
  26. if game[2][0] == 1:
  27. print("First player won")
  28. elif game[2][0] == 2:
  29. print("Second player won")
  30. else:
  31. pass
  32.  
  33. # first column
  34. elif game[0][0] == game[1][0] and game[2][0]:
  35. if game[0][0] == 1:
  36. print("First player won")
  37. elif game[0][0] == 2:
  38. print("Second player won")
  39. else:
  40. pass
  41.  
  42. # second column
  43. elif game[0][1] == game[1][1] and game[2][1]:
  44. if game[0][1] == 1:
  45. print("First player won")
  46. elif game[0][1] == 2:
  47. print("Second player won")
  48. else:
  49. pass
  50.  
  51. # third column
  52. elif game[0][2] == game[1][2] and game[2][2]:
  53. if game[0][2] == 1:
  54. print("First player won")
  55. elif game[0][2] == 2:
  56. print("Second player won")
  57. else:
  58. pass
  59.  
  60. # left diagonal
  61. elif game[0][0] == game[1][1] and game[2][2]:
  62. if game[0][0] == 1:
  63. print("First player won")
  64. elif game[0][0] == 2:
  65. print("Second player won")
  66. else:
  67. pass
  68.  
  69. # right diagonal
  70. elif game[0][2] == game[1][1] and game[2][0]:
  71. if game[0][2] == 1:
  72. print("First player won")
  73. elif game[0][2] == 2:
  74. print("Second player won")
  75. else:
  76. pass
  77. else:
  78. print("Draw!")
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement