Advertisement
Guest User

xo gra

a guest
Mar 10th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. def board(f):
  2.  
  3. b1 = (" "+f[7]+" | "+f[8]+" | "+f[9]+" ")
  4. b2 = ("-----------")
  5. b3 = (" "+f[4]+" | "+f[5]+" | "+f[6]+" ")
  6. b4 = ("-----------")
  7. b5 = (" "+f[1]+" | "+f[2]+" | "+f[3]+" ")
  8.  
  9. print(b1)
  10. print(b2)
  11. print(b3)
  12. print(b4)
  13. print(b5)
  14.  
  15.  
  16.  
  17. def welcomescreen():
  18. import random
  19.  
  20. f = [" ", " ", " ", " ", " ", " ", " ", " ", " ", " "]
  21.  
  22. figures = ["X", "O"]
  23. figuresc = False
  24. p1 = input("Hello player one, enter your name:")
  25. while figuresc == False:
  26.  
  27. f1 = input(f"Hello {p1}, what do you choose? Type X, O or Random:")
  28. if f1 == "X":
  29. f2 = "O"
  30. figuresc = True
  31. elif f1 == "O":
  32. f2 = "X"
  33. figuresc = True
  34. elif f1 == "Random":
  35. f1 = random.choice(figures)
  36. if f1 == "X":
  37. f2 = "O"
  38. figuresc = True
  39. elif f1 == "O":
  40. f2 = "X"
  41. figuresc = True
  42. else:
  43. print("Incorrect input, try again")
  44. print(f"Your figure is {f1}")
  45.  
  46.  
  47. p2 = input("Hello player two, enter your name:")
  48. print(f"Hello {p2}, your figure is {f2}")
  49.  
  50.  
  51.  
  52. def choosing():
  53. spotchoice = True
  54. while spotchoice == True:
  55. ch1 = input(f"Where would you like to place {f1}?")
  56. if ch1 in [1,2,3,4,5,6,7,8,9] and f[ch1] == " ":
  57. f[ch1] = f1
  58. f.pop(f[ch1])
  59. board(f)
  60. ch2 = input(f"Where would you like to place {f2}?")
  61. if ch2 in [1,2,3,4,5,6,7,8,9] and f[ch2] == " ":
  62. f[ch2] = f2
  63. f.pop(f[ch2])
  64. board(f)
  65. else:
  66. print("Incorrect input! Try again")
  67. board(f)
  68. else:
  69. print("Incorrect input! Try again")
  70. board(f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement