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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:52:01+00:00 2026-06-18T01:52:01+00:00

Ex. Lets consider, I have a list, list_var = [‘sales_qty’ , ‘returns_qty’ , ‘net_sales_qty’

  • 0

Ex. Lets consider, I have a list,

list_var = ['sales_qty' , 'returns_qty' , 'net_sales_qty' , 'sales_amt' , 'returns_amt' ,'product_discount_amt' , 'product_net_amt' ,'product_cost_amt' , 'gross_sales_amt' , 'supplier_disc_amt' , 'category_disc_amt' , 'topup_disc_amt' , 'value_at_cost']

from this list element, i want to init these elements as list in the memory, so i could use append, extend method for these elements.

As follow,

#Need these variable in memory..
sales_qty = [], returns_qty  = [], net_sales_qty = [] ... value_at_cost = []

#list operation on variable..
sales_qty.append(5)

Is there any simple way to do that, so i could remove element or add element in list easily?

  • 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-18T01:52:02+00:00Added an answer on June 18, 2026 at 1:52 am

    You could create a dictionary of lists based on list_var .

    list_var = ['sales_qty' , 'returns_qty' , 'net_sales_qty' , 'sales_amt' , 'returns_amt' ,'product_discount_amt' , 'product_net_amt' ,'product_cost_amt' , 'gross_sales_amt' , 'supplier_disc_amt' , 'category_disc_amt' , 'topup_disc_amt' , 'value_at_cost']
    
    list_dic = {k: [] for k in list_var}
    

    Now can access your lists through the list_dic dict:

    list_dic['sales_qty'].append(123)
    list_dic['category_disc_amt'].append('abc')
    

    If you’re using a python version that does not support dict comprehensions (python 2.6 or lower), you can use a list comprehension instead (as DSM explained in his comment):

    list_dic = dict((k, []) for k in list_var)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
Lets consider I have a table 'Tab' which has a column 'Col' The table
I've a doubt. Lets consider that we have a div of width 200px. If
I have a question about HTTPService and the data it returns. Well lets consider
Please consider the following scenario. I have a Task, that returns an object, lets
Lets consider I have a class inside a really long module path: sux =
Lets consider that I have a public property called AvatarSize like the following, public
Lets consider I have the following function: SomeType createSomeType(); which can throw depending on
Lets just consider the trust that the server have with the user. Session fixation:
Let's consider we have QWidget that contains QTableWidget (only). So we want to resize

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.