I'm just starting to learn Python with "Automate the Boring Stuff with Python" and I was hoping to get help with the code below.
theBoard = {'top-L': ' ', 'top-M': ' ', 'top-R': ' ', 'mid-L': ' ', 'mid-M':
' ', 'mid-R': ' ', 'low-L': ' ', 'low-M': ' ', 'low-R': ' '}
def printBoard(board):
print(board['top-L'] + '|' + board['top-M'] + '|' + board['top-R'])
print('-+-+-')
print(board['mid-L'] + '|' + board['mid-M'] + '|' + board['mid-R'])
print('-+-+-')
print(board['low-L'] + '|' + board['low-M'] + '|' + board['low-R'])
turn = 'X'
for i in range(9):
printBoard(theBoard)
print('Turn for ' + turn + '. Move on which space?')
move = input()
theBoard[move] = turn
if turn == 'X':
turn = 'O'
else:
turn = 'X'
printBoard(theBoard)
When defining the printBoard function, why is there the word board in the parentheses? Shouldn't it be theBoard instead to refer to the dictionary?
In the same block, in the line right under def printBoard(board), why does it say print(board['top-L']...?
How does the program know the 'top-L' key is in myBoard if only the word board precedes it?

