apollodriver 0 Newbie Poster

hello dear experts

i am currently creating  an 'adress book' python where i want to use dictionaries?

the plan:
I'm trying to create an little adress-book that has got an index 
the index - think would be apropiate - could be the  'nickname' in the adress-book 
I want to give some options:

with the nickname the user can do some savings:

a. save a name of a person, the address of a person and subsequently the  phone-number of that person.
well - so far so good: - i want to use use a dictionaries, i want to have such a list. e.g

myList = [["Bill","Butcher", "4433345411"],["Billiboy","2 Rue Rivoli ", "0994399394800838383"]]

And then if I wanted to see a certain contact I would just use some more code to search for a pattern. 
And then i need to figure out how to do it with a dictionary?

well - i could do some starting points  - with the usage of a dictionary: 

i could probably start with this:

my_dict = {"Don": {"name": "Donald Jones", "address": "1 Rue Rivoli Paris ", "phone": "9444444411"}, 
           "Joseph": {"name": "Joseph Boy", "address": "3 Tivoli Paris", "phone": "0800838383"}
            "Bilbo": {"name": "Bilbo Baggin", "address": "4 White House Washington", "phone": "08055550838383"}
         
         }
         

But how to get access to the records that i have created: well i can access records using

my_dict["Don"]["name"]

or like so

my_dict["Bilbo"]["phone"]

by the way: Keys in a Python dictionary tend to be  unique. Having a list of contacts in my adressbook the important thing is - there should be no name twice.  That saind - we see that  i can have the solution like this:

[python]
contacts = {}
contacts['Don'] = ["1 Rue Rivoli", 9444444411]
contacts['Joseph'] = ["3 Tivoli", 0800838383]

so adding data to a dictionary is based on the access operator []. 

the question is: how to extend the scipt a bit
should i make use of

  • raw input
  • arg.pop

how would you extend the script!?

what do you say!?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.