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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:09:23+00:00 2026-06-16T09:09:23+00:00

Ok, this is bizarre. I don’t understand and it’s getting extremely frustrating. I declare

  • 0

Ok, this is bizarre. I don’t understand and it’s getting extremely frustrating.

  1. I declare and array (list)
  2. I initiate the first row with strings (stock symbols)
  3. I populate the rest with zeros for the required number of trading days.
  4. The I want to populate certain elements of the ‘positions’ matrix with a number for stocks to be purchased or sold on that day. And instead of populating only the one element, the entire column populates.

    # Initiating position matrix
    positions = []
    # Initiating a row of zeros (to fill position matrix later)
    empty_row = []
    # Symbols is a list of symbols that will be traded.
    for symbol in symbols:
        empty_row.append(0)
    
    # First row of positions will be symbols
    positions.append(symbols)
    
    # All other rows will be empty_rows
    for day in timestamps:
        positions.append(empty_row)
    

    Then I will determine what element of “positions” I need to populate. Let’s say the element on the 10th row and 1st column (indexing from zero). So i do:

    positions[10][1] = 100

    The result I get is that the ENTIRE column 1 is full of 100s. Not just the element. What am I doing wrong?

  • 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-06-16T09:09:24+00:00Added an answer on June 16, 2026 at 9:09 am

    You’re appending the same empty list over and over:

    for day in timestamps:
        positions.append(empty_row)
    

    You need to create a new “empty” list for each new row:

    for day in timestamps:
        positions.append([0]*len(symbols))
    

    You can put all that into a list comprehension, so your entire code would become

    positions = [symbols]
    positions.extend([[0]*len(symbols) for day in timestamps])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having this bizarre error and I don't know what to do. This
I'm doing some testing and ran into this bizarre situation: The first case (assigning
I have a dictionary of list of dictionaries. Why did I pick this bizarre
This is my first post here and to be honest, I don't tend to
This behavior is so bizarre that I don't even know how best to ask
Ok, this is downright bizarre. I am building a web application that relies on
This was a very bizarre scenario I just witnessed on a colleague's machine. While
This is gcc 4.4.6 on Linux. Here's the behavior bizarre.c double a[500000000]; main() {
I'm running into a bizarre problem with a C++ makefile. I rewrote it this
this is my first question in here, and I would like to ask if

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.