Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5953161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:47:06+00:00 2026-05-22T17:47:06+00:00

Code: http://pastie.org/1961455 Trackback: Traceback (most recent call last): File C:\Users\COMPAQ\Desktop\NoughtsCrosses.py, line 149, in <module>

  • 0

Code:

http://pastie.org/1961455

Trackback:

Traceback (most recent call last):
  File "C:\Users\COMPAQ\Desktop\NoughtsCrosses.py", line 149, in <module>
    main ()
  File "C:\Users\COMPAQ\Desktop\NoughtsCrosses.py", line 144, in main
    move = computer_move(computer, board, human)
  File "C:\Users\COMPAQ\Desktop\NoughtsCrosses.py", line 117, in computer_move
    board[i] = computer
TypeError: 'str' object does not support item assignment

As you can see for in my tic-tac-toe program, the board[i] = computer line in the computer_move function is the one (if I am reading this right) causing the error. But if I know this right, item assignment is allowed in lists, and I create a local copy of “board” for my function so that I can reassign values and whatnot within the function…

Any input at all would be greatly appreciated. This is my first serious piece of code, so if the function in question looks too mangled

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:47:07+00:00Added an answer on May 22, 2026 at 5:47 pm

    The problem is here:

    def computer_move (computer, board, human):
        best = (4,0,8,2,6,1,3,5,7)
        board = board [:]
        for i in legal_moves(board):
            board[i] = computer
            if winner(board) == computer:
                return i
            board = EMPTY
    

    At the end of the function, you assign EMPTY to board, but EMPTY is an empty string, as defined on line 4. I assume you must have meant board[i] = EMPTY.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please see the code here: http://pastie.org/1092106 When I call the method createPost on Blog,
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
My .plist and code to read it is described in http://pastie.org/605082 NSLog(@Test %@\n,[test valueForKey:@FirstName]);
This is the IMDB code http://pastie.org/private/s8m72fndjvqzdtcjjel5w and in order to use it I must
This is the IMDB code http://pastie.org/private/s8m72fndjvqzdtcjjel5w and in order to use it I must
See this simple HTML code: http://www.pastie.org/3540274 On modern browsers and even IE8 and IE9
I am using this code in my templatetags: http://pastie.org/3530409 And I know for context
I have little problem with my script. Here is the code. http://pastie.org/2361140 When I
The following code: http://pastie.org/pastes/835022 in a custom UIView rotates the entire view including the
I have the following html / Javascript: http://pastie.org/782618 And the following Zend PHP Code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.