Tic Tac Toe game using python class concept.

class Tic_Tack:
    def __init__(self):
        self.count =0
        self.t_data =[1,2,3,4,5,6,7,8]
        self.name='X'
        self.name2='O'
    def check(self,f_name):
        f_list=self.t_data
        if (f_list[0]==f_list[1] and f_list[1]==f_list[2]) or (f_list[3]==f_list[4] and f_list[3]==f_list[5]) or (f_list[6]==f_list[7] and f_list[6]==f_list[8]) or (f_list[0]==f_list[3] and f_list[0]==f_list[6]) or (f_list[1]==f_list[4] and f_list[1]==f_list[7]) or (f_list[2]==f_list[5] and f_list[2]==f_list[8]) or (f_list[6]==f_list[4] and f_list[6]==f_list[2]) or (f_list[0]==f_list[4] and f_list[0]==f_list[8]):
            print("You won",f_name)
            self.table(f_list)
            return True
    def take_input(self,p_name,letter):
        t_list=self.t_data
        step=self.count
        print("Your turn  ", p_name, '>>>\t\t')
        ch = int(input())
        if ch <= 9:
            ch = (ch - 1)
            if t_list[ch] != 'O' and t_list[ch] != 'X':
                t_list[ch] = letter
                step += 1
                if self.check(p_name):
                    self.replay()
                    print("NEW GAME")
                    step = 0
            else:
                print("Enter valid choice:")
                self.take_input(p_name,letter)
            return step
        else:
            print("Enter valid choice:")
            self.take_input(p_name,letter)

    def replay(self):
        t_list=self.t_data
        again_play = input("Enter Y to play again >>>\t\t")
        if again_play == 'Y' or again_play == 'y':
            for x in range(len(t_list)):
                t_list[x] = x + 1
            count = 0
        else:
            print("Bye!!!")
            exit(0)

    def table(self,t_t_list):
        t_t_list=self.t_data
        print('          |          |')
        print('   ', t_t_list[0], '    |   ', t_t_list[1], '    |   ', t_t_list[2])
        print('__________|__________|__________')
        print('          |          |')
        print('   ', t_t_list[3], '    |   ', t_t_list[4], '    |   ', t_t_list[5])
        print('          |          |')
        print('__________|__________|__________')
        print('          |          |')
        print('   ', t_t_list[6], '    |   ', t_t_list[7], '    |   ', t_t_list[8])
        print('          |          |')
    # class end here-
    def start(self):
        count=self.count
        t_list=self.t_data
        while True:
            self.table(t_list)
            if count % 2 == 0:
                count = self.take_input(self.name,'X')
            else:
                count = self.take_input(self.name2,'O')
            if count >= 9:
                print("******Game Tie******")
                print("******Game over******")
                self.replay()
                print("NEW GAME")
new=Tic_Tack()
new.start()
#by admin Download Pdf