logo codesdope

Unobserveable error in tic tac toe program.

   Anita Sahu

I am beginner and decided to write a program for tic tac toe and I found that I m stuck in one error which I can't observe when I give input move as 1,2,3,4,5 and 6 program ends fine after getting a combo of 3 but when I include 7,8 and 9 In input move it programs does not end

 

 

import random

import time

 

def k_kno():

a='[1] | [2] | [3]'

b='[4] | [5] | [6]'

c='[7] | [8] | [9]'

d='_______________'

k_opt= str(input('do you want to know input keys to play game(Y/N) :'))

time.sleep(.5)

if  k_opt=='y' or k_opt=='Y':

print('')

print(a)

print(d)

print(b)

print(d)

print(c)

time.sleep(1)

print('')

print('ok lets proceed towards game')

else:

time.sleep(.5)

print('')

print('ok lets proceed towards game')

time.sleep(.5)

 

alv_move=[1,2,3,4,5,6,7,8,9]

 

def game():

a='[1] | [2] | [3]'

b='[4] | [5] | [6]'

c='[7] | [8] | [9]'

d='_______________'

while a[1]!=a[7]==a[13] or a[1]==a[7]!=a[13] or a[1]!=a[7]!=a[13] and b[1]!=b[7]!=b[13] or b[1]!=b[7]==b[13] or b[1]==b[7]!=b[13] and c[1]!=c[7]!=c[13] or c[1]!=c[7]==c[13] or c[1]==c[7]!=c[13]  and a[1]!=b[7]!=c[13] or a[1]!=b[7]==c[13] or a[1]==b[7]!=c[13] and a[13]!=b[7]!=c[1] or a[13]==b[7]!=c[1] or a[13]!=b[7]==c[1] and a[1]!=b[1]!=c[1] or a[1]==b[1]!=c[1] or a[1]!=b[1]==c[1] and a[13]!=b[13]!=c[13] or a[13]==b[13]!=c[13] or a[13]!=b[13]==c[13] and a[7]!=b[7]!=c[7] or a[7]==b[7]!=c[7] or a[7]!=b[7]==c[7] :

 

print('')

pO=int(input('enter your move:'))

if pO==1:

a=a.replace('[1] ',' O  ')

print(a)

print(d)

print(b)

print(d)

print(c)

elif pO==2:

a=a.replace('[2]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c) 

elif pO==3:

a=a.replace('[3]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c)

elif pO==4:

b=b.replace('[4]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c)

elif pO==5:

b=b.replace('[5]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c)

elif pO==6:

b=b.replace('[6]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c)

if pO==8:

c=c.replace('[8] ',' O  ')

print(a)

print(d)

print(b)

print(d)

print(c)

elif pO==9:

c=c.replace('[9]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c) 

elif pO==7:

c=c.replace('[7]',' O ') 

print(a)

print(d)

print(b)

print(d)

print(c)

else:

print('invalid move, turn cut') 

print('game over')

k_kno()

game() 


Answers

Write your answer
Close

Welcome.please sign up.

Close

Welcome.please login.