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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:03:41+00:00 2026-06-16T02:03:41+00:00

I am new to python and am trying to grasp a few things. I

  • 0

I am new to python and am trying to grasp a few things. I would like to create a dictionary from two lists. I have two sets of data:

Person  |    Name
--------|--------
1       |   Jimmy
2       |    Mike
3       | Stanley
4       |    Will

I have both of these in lists, one called “person” and one called “name”. I do this in a script which runs through multiple files to pull the data. each list is a different length with different data in it. Essentially, what I want to do is print the data as like this:

1 \t Jimmy
2 \t Mike
3 \t Stanley
4 \t Will

I pull the data from an xml file and here is the code I use to pull the data:

for people in xml.iter('people'):
  person.append(people.find('person').text)
  name.append(people.find('name').text)

So far the script works great and I can print out the two lists separately. What I don’t know how to do is print them out together and so my thought is to store them to a dictionary instead, but I don’t really know how to do that.

  • 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-16T02:03:42+00:00Added an answer on June 16, 2026 at 2:03 am

    If you just want to print the two lists you can use zip (doc)

    for num,name in zip(num_list,name_list):
        print str(num) + '\t' + name
    

    you can use the same form to put the pairs in a dictionary (after you have the lists)

    name_dict = {}
    for num,name in zip(num_list,name_list):
        name_dict[num] = name
    

    and then print

    for num,name in name_dict.iteritems():
        print str(num) + '\t' + name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started to look into python and am trying to grasp new things
Im new two python and am trying to grow a dictionary of dictionaries. I
New to Python, have a simple, situational question: Trying to use BeautifulSoup to parse
I'm new to Python and I have been trying to search through html with
I am trying to fork() and exec() a new python script process from within
I'm new to python and am trying to read blocks of data from a
I'm new to Python OOP and trying to create a OOP program to manage
I'm trying to create an environment using virtualenv. virtualenv test New python executable in
I'm new to Python and I'm trying to create a simple GUI using Tkinter.
I am new to python and I'm trying to create a program that creates

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.