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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:20:20+00:00 2026-05-27T01:20:20+00:00

Here’s my problem, I have two different lists, list a which contains the name

  • 0

Here’s my problem, I have two different lists, list a which contains the name of people and list b which contains their phone numbers:

a = ["peter", "bob", "john", "jack"]
b = ["8954 3434", "8999 4432", "8976 5443", "8990 3331"]

What I need to do is prompt users for a input which will be a name from list a and then python should automatically print out the phone number for that person from list b.

I came across a code that seems pretty interesting:

for x, y in zip(a, b):
    print x, y

This pretty much prints every single name and the corresponding phone number next to it which is basically what I need, however rather than every name from list a appearing, what I need is for the user to be able to enter a single name and for that names phone number to show up.

Just to clarify, using the above code gives me the output:

peter 8954 3434
bob 8999 4432
john 8976 5443
jack 8990 3331

While what I want is for the user to be able to enter a name e.g “peter” which should give the output:

peter 8954 3434

Is there a way to edit that above code to get things to work properly? Thanks for any help.

  • 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-27T01:20:21+00:00Added an answer on May 27, 2026 at 1:20 am

    The most basic way to solve this:

    who = raw_input("Give a name")
    for name, number in zip(a, b): 
        if name == who:
            print name, number
    

    I hope it’s homework.

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

Sidebar

Related Questions

Here's my problem: I have do create a menu/list of actions (which would be
Here's the problem. In my app, I have 5 tabs which contains activities. In
I have a bit of an architecture problem here. Say I have two tables,
Here's my problem at a high level: We have two business applications. App1 inputs
Here is the problem I have: I have a lot (tens of thousands) of
Here's my problem - I have some code like this: <mx:Canvas width=300 height=300> <mx:Button
Here's my problem: I have a virtual method defined in a .h file that
Here is the problem: we have lots of Javascripts and lots of CSS files,
Here's my problem: I have to call a web service with a secure header
Here's my problem.I have 2 xmlfiles with identical structure, with the second xml containing

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.