![]() ![]() (bo = le and bo = le and bo = le) or # down the left side (bo = le and bo = le and bo = le) or # across the bottom (bo = le and bo = le and bo = le) or # across the middle Return ((bo = le and bo = le and bo = le) or # across the top # We use bo instead of board and le instead of letter so we don't have to type as much. # Given a board and a player's letter, this function returns True if that player has won. ![]() Print('Do you want to play again? (yes or no)') # This function returns True if the player wants to play again, otherwise it returns False. # Randomly choose the player who goes first. # the first element in the tuple is the player's letter, the second is the computer's letter. While not (letter = 'X' or letter = 'O'): # Returns a list with the player's letter as the first item, and the computer's letter as the second. # Let's the player type which letter they want to be. Print(' ' + board + ' | ' + board + ' | ' + board) # "board" is a list of 10 strings representing the board (ignore index 0) # This function prints out the board that it was passed. Other threads that I have tried don't seem that useful. I have tried changing the letter to a string on line 27, but that doesn't solve the problem. PlayerLetter, computerLetter = inputPlayerLetter()įile "tictactoe.py", line 27, in inputPlayerLetter However, when I run it I get this error: PS C:\python33> python tictactoe.py I am using the code below to play Tic-Tac-Toe.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |