Python Forum
creating an 'adress book' in python using dictionaries?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
creating an 'adress book' in python using dictionaries?
#1
hello dear Python-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"]
BTW
: 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:
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!?



love to hear from you
apollo LOL
Wordpress - super toolkits a. http://wpgear.org/ :: und b. https://github.com/miziomon/awesome-wordpress :: Awesome WordPress: A curated list of amazingly awesome WordPress resources and awesome python things https://github.com/vinta/awesome-python
Reply


Messages In This Thread
creating an 'adress book' in python using dictionaries? - by apollo - May-04-2019, 10:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner stuck in Python book for kids mic81k 11 1,608 Nov-27-2023, 04:28 AM
Last Post: deanhystad
  Deitel book "Python for Programmers" ricardian 7 28,003 May-12-2023, 01:33 PM
Last Post: snippsat
  best " Learning Python " book for a beginner alok 4 3,216 Jul-30-2021, 11:37 AM
Last Post: metulburr
  Nested Python functions (Dan Bader's book) Drone4four 4 2,751 Jun-26-2021, 07:54 AM
Last Post: ndc85430
  I really need help, I am new to python, I am using a book that helps me to learn JaprO 5 3,262 Nov-28-2020, 02:30 PM
Last Post: JaprO
  Creating a list of dictionaries while iterating pythonnewbie138 6 3,472 Sep-27-2020, 08:23 PM
Last Post: pythonnewbie138
  listdir on IP Adress OEMS1 3 3,088 Jul-19-2020, 06:01 PM
Last Post: bowlofred
  Creating Nested Dictionaries Confusion gw1500se 2 2,259 May-18-2020, 11:16 PM
Last Post: gw1500se
  creating a list of dictionaries from API calls AndrewEnglsh101 5 3,295 Apr-03-2020, 02:21 PM
Last Post: AndrewEnglsh101
  Data Dictionaries in Python mrsenorchuck 16 7,783 Nov-25-2019, 09:29 PM
Last Post: mrsenorchuck

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020