Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def printboard(board):
- print(board[1] + " | " + board[2] + " | " + board[3])
- print("- + - + -")
- print(board[4] + " | " + board[5] + " | " + board[6])
- print("- + - + -")
- print(board[7] + " | " + board[8] + " | " + board[9])
- def get_input(turn, board):
- while True:
- print(turn+ "'s turn")
- position = input("Enter the position you want to play. ")
- if not position.isdigit():
- print("Please enter a valid number")
- elif not 1 <= position <= 9:
- print("Enter the number in valid range")
- elif not board.isdigit():
- print("Position already taken. ")
- else:
- return int(position)
- def main():
- turn = "X"
- board = ["0", "1", "2", "3", "4", "5","6", "7", "8","9"]
- game_over = False
- printboard(board)
- while not game_over:
- pos = get_input(turn, board)
- main()
Add Comment
Please, Sign In to add comment