Skip to content

Instantly share code, notes, and snippets.

@shamikalashawn
Created February 1, 2017 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shamikalashawn/d540e12e8bbe4c7ee121690d1ca78729 to your computer and use it in GitHub Desktop.
Save shamikalashawn/d540e12e8bbe4c7ee121690d1ca78729 to your computer and use it in GitHub Desktop.
The skeleton of the game is there. X and O take turns and the gameboard updates with each round.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment