Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. def ruch(gracz):
  2.  
  3.   # Get position from player
  4.   print(gracz + "'s turn.")
  5.   pozycja = input("Choose a position from 1-9: ")
  6.  
  7.   # Whatever the user inputs, make sure it is a valid input, and the spot is open
  8.   valid = False
  9.   while not valid:
  10.  
  11.     # Make sure the input is valid
  12.     while pozycja not in ["1", "2", "3", "4", "5", "6", "7", "8", "9"]:
  13.       pozycja = input("Choose a position from 1-9: ")
  14.  
  15.     # Get correct index in our board list
  16.     pozycja = int(pozycja) - 1
  17.  
  18.     # Then also make sure the spot is available on the board
  19.     if plansza[pozycja] == "-":
  20.       valid = True
  21.     else:
  22.       print("You can't go there. Go again.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement