0

Creating a Phonebook in Python

I have a phonebook that can add, delete, print and search contacts, What to write code that can be update ? Thanks for your guidance https://code.sololearn.com/cAuz4P8l4g5u/?ref=app

20th Dec 2019, 1:50 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar
13 Answers
+ 2
First, how is the information stored ? There are multiple ways an information can be stored in files, and different separators. Share a sample heee that contains two or three contacts.
13th Jan 2020, 8:34 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Mσみคოคの ʝคงค๔ คłıķみσňı I meant how are they stored in the file. How does the file that contains the contacts look like ?
13th Jan 2020, 8:44 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Like this ? name\tnumber
13th Jan 2020, 9:10 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Mσみคოคの ʝคงค๔ คłıķみσňı that has everything to do with dictionnary manipulation, and nothing to do with files. 1. You can easily add to a dictionarry. 2. You can easily edit a dictionarry. 3. You can easily view it. 4. ... same goes for all the others After you're done, all you have to do is write to the file again.
13th Jan 2020, 9:42 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Mσみคოคの ʝคงค๔ คłıķみσňı can you send the whole problem then ? Always link everything correctly, because then the answers would only be confusing. My solution is technically the answer, so please make sure to post the whole problem text next time, so I and other people who answer know what the solution should look like, otherwise neither us or you will be satisfied.
13th Jan 2020, 9:48 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Mσみคოคの ʝคงค๔ คłıķみσňı well you can take my answer, and instead of reading the file once, and writing to it at the end, just read it inside each function, and write it inside the same function again. (Not very practical) I do not have access to my laptop now, I'll try to write a sample when I can. In the meanwhile, you can try implementing the idea in your code, it isn't so hard. Good luck!
13th Jan 2020, 9:56 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Aymane Boukrouh [INACTIVE] The code must read a file or write a text file and the values ​​stored in the phonebook are stored in the text file . The code I wrote only works to add it. https://code.sololearn.com/c4999AIrHU6m/?ref=app
13th Jan 2020, 8:38 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar
0
Aymane Boukrouh [INACTIVE] In the text file, the name and number are displayed at a distance from a tab
13th Jan 2020, 8:53 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar
0
Aymane Boukrouh [INACTIVE] Yes Name\tnumber\n Next values!
13th Jan 2020, 9:11 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar
0
Mσみคოคの ʝคงค๔ คłıķみσňı well then all you have to do is make them in a dictionnary: with open("file.txt") as f: d = {line.split("\t")[0] : line.split("\t")[1] for line in f.read().split("\n")} (I haven't tested the code)
13th Jan 2020, 9:26 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
Aymane Boukrouh [INACTIVE] See the code I sent you. I want the phonebook slave to have the following capabilities. 1.Add Contacts 2. Edit Contacts 3.View All Contacts List 4.Edit Contacts 5.Search Contacts 6Have an exit
13th Jan 2020, 9:39 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar
0
Aymane Boukrouh [INACTIVE] Yes, but the docs said it should not be a dictionary or a list, and all values ​​should be stored in a single file at a time. And the text file must be written or read in a moment.
13th Jan 2020, 9:45 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar
0
I'm really sorry and sorry for that You see the code below you might understand what I mean https://code.sololearn.com/cumFd06upGrw/?ref=app I want the code to do the same thing you see in the code above, but the code above is not standard and has a problem Aymane Boukrouh [INACTIVE]
13th Jan 2020, 9:53 PM
Mσみคოคの ʝคงค๔ คłıķみσňı
Mσみคოคの ʝคงค๔ คłıķみσňı - avatar