Posts

Showing posts from 2017

The Tic-Tac-Toe Game in Python

It's always fun to implement simple games and small projects after learning the basics of any programming language. Following is the implementation of the TicTacToe game in python. theBoard = {'7': ' ' , '8': ' ' , '9': ' ' ,             '4': ' ' , '5': ' ' , '6': ' ' ,             '1': ' ' , '2': ' ' , '3': ' ' } board_keys = [] for key in theBoard:     board_keys.append(key) def printBoard(board):     print(board['7'] + '|' + board['8'] + '|' + board['9'])     print('-+-+-')     print(board['4'] + '|' + board['5'] + '|' + board['6'])     print('-+-+-')     print(board['1'] + '|' + board['2'] + '|' + board['3']) # The main function  def game():     turn = 'X'     count = 0     for i in range(10):  ...