table=[ [' ','|',' ','|',' '] ,['-','-','-','-','-'], [' ','|',' ','|',' '], ['-','-','-','-','-'], [' ','|',' ','|',' '],] def CTable(): AiOT=[ [' ','|',' ','|',' '] ,['-','-','-','-','-'], [' ','|',' ','|',' '], ['-','-','-','-','-'], [' ','|',' ','|',' '],] def PTable(): for y in range(5): for x in range(5): print(table[y][x],end="") print('\n') def Uinput(): y=int(input("Please enter row:")) x=int(input("Please enter column:")) z=input("please ener 's' or 'o':") if y==3: y=4 elif y==1: y=0 if x==3: x=4 elif x==1: x=0 if table[y][x]==' ': table[y][x]=z else: print("location occupied try again") Uinput() AiOT=table c=[False,False,False,False,False,False,False,False] def AiO(): global table global c global AiOT score=0 for y in [0,2,4]: for x in [0,2,4]: for z in ['s','o']: if table[y][x]==' ': AiOT[y][x]=z if AiOT[0][0]=='s' and AiOT[0][2]=='o' and AiOT[0][4]=='s' and c[0]==False: score=score+1 elif AiOT[2][0]=='s' and AiOT[2][2]=='o' and AiOT[2][4]=='s' and c[1]==False: score=score+1 elif AiOT[4][0]=='s' and AiOT[4][2]=='o' and AiOT[4][4]=='s' and c[2]==False: score=score+1 elif AiOT[0][0]=='s' and AiOT[2][0]=='o' and AiOT[4][0]=='s' and c[3]==False: score=score+1 elif AiOT[0][2]=='s' and AiOT[2][2]=='o' and AiOT[4][2]=='s' and c[4]==False: score=score+1 elif AiOT[0][4]=='s' and AiOT[2][4]=='o' and AiOT[4][4]=='s' and c[5]==False: score=score+1 elif AiOT[0][0]=='s' and AiOT[2][2]=='o' and AiOT[4][4]=='s' and c[6]==False: score=score+1 elif AiOT[0][4]=='s' and AiOT[2][2]=='o' and AiOT[4][0]=='s' and c[7]==False: score=score+1 if score>0: table=AiOT[:] break else: AiOT=table if score>0: break if score>0: break def execute(): x=True while x==True: PTable() Uinput() AiO()