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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:35:35+00:00 2026-06-02T01:35:35+00:00

I want to write a python script that creates several dictionaries at once then

  • 0

I want to write a python script that creates several dictionaries at once then print the dictionaries out but I don’t know how to convert a string to a variable.

number = 0

while (number < 10):
    number = number + 1
    dictionarynumber = ("D"+str(number)) # creates the dictionarys name(D1,D2,D3,D4,D5,D6,D7,D8,D9,D10)
    var(dictionarynumber) = {"Fruit":"Apple","Book":"Oliver Twist","Building":"White House"} #Of course var() doesn't work but I placed it here to get my point across
    print(dictionarynumber)

After Answers:

I liked the idea about dictionaries and taking out the unneeded “D” makes sense. What do you guys think of this?

dict = {}
n = 0

while (n < 10):
    n = n + 1
    d = n
    d = {"Key":"Information"}
    dict[n] = d

print(dict)


# Output = 
#          {1: {'Key': 'Information'},
#           2: {'Key': 'Information'},
#           3: {'Key': 'Information'},
#           4: {'Key': 'Information'},
#           5: {'Key': 'Information'},
#           6: {'Key': 'Information'},
#           7: {'Key': 'Information'},
#           8: {'Key': 'Information'},
#           9: {'Key': 'Information'},
#           10: {'Key': 'Information'}}
  • 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-02T01:35:36+00:00Added an answer on June 2, 2026 at 1:35 am

    If you want to give each dictionary a name, put them in a dictionary.

    dicts = {}
    # dict_list = []
    for i in xrange(10):
        dictionary_key = ('d{0}'.format(i))
        dict_item = {"Fruit":"Apple","Book":"Oliver Twist","Building":"White House"}
        dicts[dictionary_key] = dict_item
        # dict_list.append(dict_item)
    

    If you’re not hung up on using a name for your dictionaries, put them in a list.

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

Sidebar

Related Questions

I want to write a simple python script that send a EML file exported
I want to write a python script that populates a database with some information.
I want to write a python script on Windows that saves the title of
I want to write a python script that calls some external REST service and
I want to write a python script that takes 3 parameters. The first parameter
I want to write a Python script that runs another program, reading the output
I want to write a Python script that will check the users local network
I am trying to write out a python cgi script that will redirect me
I'm learning Python right now and I want to write some script that will
I want to write a Python script that reads in an Excel spreadsheet and

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.