Python code for tic-tac-toe