Question: Please write a python function for this question. Thank you. Write a function named game () that accepts one argument, the number of players. The

Please write a python function for this question. Thank you.Please write a python function for this question. Thank you. Write a

Write a function named game () that accepts one argument, the number of players. The game () function should complete the following tasks: Initialize a List of 9 empty Strings representing the 9 squares in the Tic-Tac-Toe board O HINT: This could be 9 Strings with each containing a single space character Draw the initial (empty) game grid Setup a for loop that repeats 9 times o If it's a human player's turn: . Prompt for a grid location to place their marker (ie: "A1") . If the selected location is outside the game grid (ie: "Al") . Continue to prompt the player until a a valid grid location is entered . If the selected grid location is not empty: . Continue to prompt the player until an empty grid location is entered . Update the corresponding List location with the correct player marker (x or O) o Else if it's the computer player's turn: . Select a random, empty grid location and place the o marker. o Draw the updated grid including the player's marker o call the check() function with the List as an argument to determine if there's a winner o If a player has won the game: . Display winning message and end the game () function Display "game is a tie" message as shown in the example output

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!