Question: python Where and how could i improve to solve this queation. ck results 1 2 out of Finish attem question Complete the player_turn() function that

 python Where and how could i improve to solve this queation.

ck results 1 2 out of Finish attem question Complete the player_turn()

function that completes a single turn of the game Tic-Tac-Toe (also called

Noughts and Crosses). The function takes 3 parameters: 1. The first parameter

python Where and how could i improve to solve this queation.

ck results 1 2 out of Finish attem question Complete the player_turn() function that completes a single turn of the game Tic-Tac-Toe (also called Noughts and Crosses). The function takes 3 parameters: 1. The first parameter is called board. It is a list of length 3, where each element is a string with 3 characters representing a row on a Tic-Tac-Toe board. Each character in a row represents a slot on the Tic-Tac-Toe board with the "#" character indicating an empty slot. An empty board looks like this: ### ### ### 2. The second parameter is called position. You can assume that it will always be an integer value between 1 and 9 inclusive, indicating the slot on the Tic-Tac-Toe board the player is interested in. Slots on the board are numbered as follows: 123 456 789 3. The third parameter is called player. It is a single character string indicating whether the player is "0" or The function should update the board with the player character if the slot they have chosen is vacant. Otherwise the function prints the following error message: "Invalid move, try again." Two examples of the function being used are shown below. Note that the print_board function has been provided for you and you must not change it in any way. For example: Test Result Test Result board = ["###", "###" ###"] Start print("Start") print() ### print_board(board) print(" Turn 1") ### player_turn(board,5, "X") print() Turn 1 print_board(board) ### #X# ### Start - board = print("Start") print) print_board(board) print(" Turn 1") player_turn(board,5,"X") print) print_board (board) print(" Turn 2") player_turn(board, 5,"0") print) print_boardboard Turn 1 #x# Turn 2 Invalid mole, try again ## Answer: (penalty regime: 0 %) Reset answer 1def player_turn(board, position, player): 2. position int(position) 3 m = position // 3 position % 3 5 if board[m][n] board[m][n] player 7 else: . print("Invalid move, try again.") 9 10 #complete this function 11 12 13 def print_board (board): 147 for row in board: 15 print (row) I Precheck only Test Expected Got 11 RE Start board ["###". "###"] Start print("Start") print print_board(board) print(" Turn 1") ### player_turn(board, 5, "X") print Turn 1 print_board(board) ### Turn 1 ### #X *** Error*** Traceback (most recent call last): File |_tester__.python3", line 44, in player_turn (board, 5, "X") tester__.python3", line 6, in player_turn board[m][n] = player TypeError: 'str' object does not support item assignmen File

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!