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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:38:31+00:00 2026-06-02T23:38:31+00:00

I’m currently learning the basics in Python, and I need to create a name

  • 0

I’m currently learning the basics in Python, and I need to create a name database of ten people, including other details (phone number, address, birthday, and three interests).

The dream is that upon entering a persons name at the prompt, all of their details will appear. Or upon entering name['phone'], the persons name and phone number will come up. Same for address, birthday, and interests. I’ve been told that I have to able to get the name and relevant field (phone, hobbies, etc) from the command line, using the argv list, but I’m not sure how to do this. Any help would be much appreciated!

Here is an example of what I’ve written up for the dictionary:

friends = {'Matt ' : {'phone' : '13579', 
                      'birthday' : '2 Dec', 
                      'address' : 'Sydney',
                      'interests' : ['a', 'b', 'c' ]},

           'Tim ' : {'phone' : '24680', 
                     'birthday' : '19 Feb', 
                     'address' : 'Honolulu',
                     'interests' : ['x', 'y', 'z' ]},

           'Kate ' : {'phone' :'12345', 
                      'birthday' : '30 Jun', 
                      'address' : 'Beijing',
                      'interests' : ['q', 'w', 'e' ]}
           }

name = raw_input ('Please enter search criteria: ')

if name in friends: 
    print 'yes'
else: 
    print 'no data'

Thank you kindly!

  • 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-02T23:38:33+00:00Added an answer on June 2, 2026 at 11:38 pm

    First of all, you must have your dictionary keys in a consistent style. I mean, either all of them mights start with a capital or all of them might be upper case or lower case. Also, having whitespace in the beginnning or the end of a key is not a good choice.

    Let’s assume you have following key structure:

    friends = {'Matt' : {'phone' : '13579', 
                      'birthday' : '2 Dec', 
                      'address' : 'Sydney',
                      'interests' : ['a', 'b', 'c' ]},
    
           'Tim' : {'phone' : '24680', 
                     'birthday' : '19 Feb', 
                     'address' : 'Honolulu',
                     'interests' : ['x', 'y', 'z' ]},
    
           'Kate' : {'phone' :'12345', 
                      'birthday' : '30 Jun', 
                      'address' : 'Beijing',
                      'interests' : ['q', 'w', 'e' ]}
           }
    

    Since all the keys start with a capital letter and have no white space at the beginning or the end, you can do the following:

    name = raw_input('Please enter search criteria: ')
    name = name.strip() # remove whitespace at the beginning and the end of the string
    name = name.capitalize() # capitilize the first letter
    

    Of course you can call string functions in a single line:

     name = name.strip().capitalize()
    

    Specific information can be get using friends[name]['<key>'].

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

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.