I need to check if spaces on my board are empty. It will return True if there are no more available spaces.
Here is my code:
#
# File: done.py
# Purpose: Complete the code in the function "done" below to determine whether a
# the game is over.
#
def print_board(board):
print(board[0:3])
print(board[3:6])
print(board[6:9])
#
# Function: string_to_list
# Purpose: converts a string to a list of characters.
def string_to_list(board):
my_list = []
for i in range(len(board)):
my_list.append(board[i])
return my_list
#
# Function done
# Input: A list of character (of length 9)
# Output: Return True if there are no remaining spaces
# Return False if there is an open spot.
def done(board):
#HERE IS WHERE I NEED HELP
board1 = "XXX XXOOO"
lboard1 = string_to_list(board1)
print("First board")
print_board(lboard1)
assert (not done(lboard1)), "The first board has a space, you returned true"
print("Test passed")
board2 = "XXXXXXOOO"
lboard2 = string_to_list(board2)
print("Second Board")
print_board(lboard2)
assert (done(lboard2)), "This second board has no space -- you returned False"
print("Test passed")
print("If you got this far, you passed the first two tests")
I need help with what goes inside of the def done(board):
I tried using if statements that would check for available spaces but I didn't really know how to start.