Question: PYTHON! Workout 1). Three of a Kind Determining whether the game is over is a bit complicated, so we're going to break it into two

PYTHON!

PYTHON! Workout 1). Three of a Kind Determining whether the game is

Workout 1). Three of a Kind Determining whether the game is over is a bit complicated, so we're going to break it into two functions. The first function is just going to take in a board and three indexes, and determine whether all of them are 'X', all of them are 'O', or neither. Don't worry about whether those indexes are actually in a row yet, we'll handle that in the next function. Write a function check_three (board, idx, idx2, idx3) that takes in the 9-element board list, along with three indexes (these should be numbers between 0 and 8, inclusive). If the elements at all three indexes are 'X', then the function should return 'X'. If the elements at all three indexes are 'o', then the function should return 'o'. Otherwise, the function should return'-'. Examples indexes being checked are highlighted for clarity): >>> check_three(['-', 'X', 'o', 'o', 'X', ', 'X', '0'], 1, 4, 7) 'X' >>> check_three(['-', 'X', 'o', 'o', 'X', '-', '-', 'X', '0'], 2, 5, 8) '-', 'X', '0'], 0, 5, 6) >>> check_three(['-', 'X', 'o', 'o', 'X', '.' '' >>> check_three(['-', 'X', 'o', 'o', 'X', ' 'X', '0'], 2, 3, 8)

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!