Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
shuru8
#python 3.5.2 print("Tic tac toe") board = ["-", "-", "-", "-", "-", "-", "-", "-", "-"] def disp(board): print(board[0] + " | " + board[1] + " | " + board[2] + " 1 | 2 | 3") print(board[3] + " | " + board[4] + " | " + board[5] + " 4 | 5 | 6") print(board[6] + " | " + board[7] + " | " + board[8] + " 7 | 8 | 9") def check(board): if board[0]=="x" and board[3]=="x" and board[6]=="x": print("X won") elif board[0]=="x" and board[1]=="x" and board[2]=="x": print("X won") elif board[0]=="x" and board[4]=="x" and board[8]=="x": print("X won") elif board[6]=="x" and board[7]=="x" and board[8]=="x": print("X won") elif board[2]=="x" and board[5]=="x" and board[8]=="x": print("X won") elif board[3]=="x" and board[4]=="x" and board[5]=="x": print("X won") elif board[6]=="x" and board[4]=="x" and board[2]=="x": print("X won") else: print("you are playing nice") check(board) def check1(board): if board[0]=="o" and board[3]=="o" and board[6]=="o": print(" o won") elif board[0]=="o" and board[1]=="o" and board[2]=="o": print("o won") elif board[0]=="o" and board[4]=="o" and board[8]=="o": print("o won") elif board[6]=="o" and board[7]=="o" and board[8]=="o": print("o won") elif board[2]=="o" and board[5]=="o" and board[8]=="o": print("o won") elif board[3]=="o" and board[4]=="o" and board[5]=="o": print("o won") elif board[6]=="o" and board[4]=="o" and board[2]=="o": print("o won") else: print("you are playing nice") check1(board) print("X's Turn.") print("Choose a position from 1-9\n") pos=int(input()) def ek(board,disp): if pos==1: board[0]="x" disp(board) elif pos==2: board[1]="x" disp(board) elif pos==3: board[2]="x" disp(board) elif pos==4: board[3]="x" disp(board) elif pos==5: board[4]="x" disp(board) elif pos==6: board[5]="x" disp(board) elif pos==7: board[6]="x" disp(board) elif pos==8: board[7]="x" disp(board) elif pos==9: board[8]="x" disp(board) else: print("pls insert between 1 to 9") ek(board,disp) print("Now O's turn.") print("Choose a position from 1-9\n") poso=int(input()) def do(board,disp): if poso==1: board[0]="o" disp(board) elif poso==2: board[1]="o" disp(board) elif poso==3: board[2]="o" disp(board) elif poso==4: board[3]="o" disp(board) elif poso==5: board[4]="o" disp(board) elif poso==6: board[5]="o" disp(board) elif poso==7: board[6]="o" disp(board) elif poso==8: board[7]="o" disp(board) elif poso==9: board[8]="o" disp(board) else: print("pls insert between 1 to 9") do(board,disp) print("Now X's turn.") print("Choose a position from 1-9\n") posx=int(input()) pos=posx ek(board,disp) print("Now O's turn.") print("Choose a position from 1-9\n") posoo=int(input()) poso=posoo do(board,disp) print("Now X's turn.") print("Choose a position from 1-9\n") posxx=int(input()) pos=posxx ek(board,disp) check(board) print("Now O's turn.") print("Choose a position from 1-9\n") posooo=int(input()) poso=posooo do(board,disp) check1(board) print("Now X's turn.") print("Choose a position from 1-9\n") posxxx=int(input()) pos=posxxx ek(board,disp) check(board) print("Now O's turn.") print("Choose a position from 1-9\n") posoooo=int(input()) poso=posoooo do(board,disp) check1(board) print("Now X's turn.") print("Choose a position from 1-9\n") posxxxx=int(input()) pos=posxxxx ek(board,disp) check(board)
run
|
edit
|
history
|
help
0
Hr
sai hw
floating point limitations
oops1.py
prime number
Tupples
Sort word in alphabetical order
Hello
Reverse linked-list in-place
Dictionary - count characters