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
14 Réponses
+ 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.
+ 2
Mσみคოคの ʝคงค๔ คłıķみσňı I meant how are they stored in the file. How does the file that contains the contacts look like ?
+ 2
Like this ?
name\tnumber
+ 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.
+ 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.
+ 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!
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
0
Aymane Boukrouh [INACTIVE]
In the text file, the name and number are displayed at a distance from a tab
0
Aymane Boukrouh [INACTIVE]
Yes
Name\tnumber\n
Next values!
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)
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
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.
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]