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

  • SEARCH
  • Home
  • 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 6164789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:03:15+00:00 2026-05-23T22:03:15+00:00

Basically there seems to be a problem when a list of lists is made

  • 0

Basically there seems to be a problem when a list of lists is made by appending a list to another list using list.append(). The problem is that the entire column is changed to the value you set it to for the index you give. for example the code here

b = [1,1,1]
c = []
c.append(b)
c.append(b)
c.append(b)
c[0][0] = 4

and if you print c you would get:
[[4,1,1][4,1,1][4,1,1]]
instead of
[[4,1,1][1,1,1][1,1,1]]

So my question is how would you be able to end up with the list to the right rather than what actually happens.

  • 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-23T22:03:16+00:00Added an answer on May 23, 2026 at 10:03 pm

    What you’ve observed is normal and expected behavior in Python and any decent tutorial should cover it.

    c.append(b)
    c.append(b)
    c.append(b)
    

    This appends to c three references to the list b. Since it’s the same list, changing one reference changes it in all four places it’s referenced, including b by the way.

    If you don’t want this behavior, copy the list.

    c.append(b[:])
    c.append(b[:])
    c.append(b[:])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some localization problems in my webpage. There are basically two problems (that
Here’s my problem, I have two different lists, list a which contains the name
::EDIT:: Ok folks, it seems that I'm an idiot after all. The problem had
I am having a problem with matching elements in jQuery. Basically I have list
Is there any equivalent to a Flash projector for iPhone? Flash projectors basically seem
Basically there are two Kinect devices. One for the Xbox and one for the
here is the code: http://jsfiddle.net/duNHJ/2/ Basically there is an animations every div so when
I just want to design this very simple website. Basically there are multiple pages
Basically I have two 2D points and there is a line between them. A
Is there any name for the following DB table design: Basically we have generic

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.