Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a={"1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9"}
- insert1=[]
- def PrintTable():
- print("-------------")
- print("|",a["1"],"|",a["2"],"|",a["3"],"|")
- print("-------------")
- print("|",a["4"],"|",a["5"],"|",a["6"],"|")
- print("-------------")
- print("|",a["7"],"|",a["8"],"|",a["9"],"|")
- print("-------------")
- def insert():
- i=0
- while True:
- insertx(insert1)
- PrintTable()
- winx=win_X()
- i+=1
- if winx==9:
- break
- if i==9:
- print("draw !!!!!!!!!!!!!!")
- break
- inserto(insert1)
- PrintTable()
- wino=win_O()
- i+=1
- if wino==9:
- break
- def insertx(insert1):
- b=input("enter x : ")
- try:
- if not(b in insert1):
- insert1+=[b]
- for c in a:
- if b==c:
- a[c]="X"
- else:
- 1/0
- except ZeroDivisionError :
- print("This place is already valued")
- insertx(insert1)
- def inserto(insert1):
- q=input("enter o : ")
- try:
- if not(q in insert1):
- insert1+=[q]
- for c in a:
- if q==c:
- a[c]="O"
- else:
- 1/0
- except ZeroDivisionError:
- print("This place is already valued")
- inserto(insert1)
- print("This place is already valued")
- def win_X():
- if a["1"]==a["2"]==a["3"] or a["4"]==a["5"]==a["6"] or a["7"]==a["8"]==a["9"] or a["1"]==a["4"]==a["7"] or a["2"]==a["5"]==a["8"] or a["3"]==a["6"]==a["9"] or a["1"]==a["5"]==a["9"] or a["3"]==a["5"]==a["7"]:
- print("Win X !!!!!!!!!!!!!!")
- return 9
- def win_O():
- if a["1"]==a["2"]==a["3"] or a["4"]==a["5"]==a["6"] or a["7"]==a["8"]==a["9"] or a["1"]==a["4"]==a["7"] or a["2"]==a["5"]==a["8"] or a["3"]==a["6"]==a["9"] or a["1"]==a["5"]==a["9"] or a["3"]==a["5"]==a["7"]:
- print("Win O !!!!!!!!!!!!!!")
- return 9
- PrintTable()
- insert()
Advertisement
Add Comment
Please, Sign In to add comment