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 7519795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:57:41+00:00 2026-05-30T01:57:41+00:00

How do I make a list with only one pointer per cell? (I think

  • 0

How do I make a list with only one pointer per cell? (I think that is the problem)

Thanks
ps if you are feeling nice, how do I take the spaces out of the print function?

class Board(object):
    """board of pieces"""
    def __init__(self):

        self.board = [['0']*7]*6 #6x7 grid
        self.board[3][6] = 8

    def printBoard(self):
        """Display the board array"""
        print self.board
        for i in range(6):
            for j in range(7):
                print self.board[i][j],
            print "\n",

0 0 0 0 0 0 8 
0 0 0 0 0 0 8 
0 0 0 0 0 0 8 
0 0 0 0 0 0 8 
0 0 0 0 0 0 8 
0 0 0 0 0 0 8 
  • 1 1 Answer
  • 0 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-30T01:57:41+00:00Added an answer on May 30, 2026 at 1:57 am

    You need to rewrite self.board as follows

    self.board = [['0']*7 for i in range(6)]
    

    Read about creating multidimentional lists in Python FAQ.

    Here is an excerpt from the answer in the FAQ.

    The reason is that replicating a list with * doesn’t create copies, it
    only creates references to the existing objects. The *3 creates a list
    containing 3 references to the same list of length two. Changes to one
    row will show in all rows, which is almost certainly not what you
    want.

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

Sidebar

Related Questions

I'm using gtk.combo_box_new_text() to make combobox list, this uses a gtk.ListStore to store only
Am I right in thinking that there's only ONE icon included in google maps,
I have a list view control which at the moment only allows one item
What Makes a Good Unit Test? says that a test should test only one
I'd like to make one list from two separate lists of unique items. There
I'm trying to make my Listview show only one record just like how DetailsView
How to make Error List window automatically active during compilation in visual studio instead
I would like to make a list of remarkable robot simulation environments including advantages
I am trying to make a list box where I have complete control over
I'm trying to make a list containing different objects. List<Object> list = new ArrayList<Object>();

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.