This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathsimple-address-book.py
71 lines (55 loc) · 1.8 KB
/
simple-address-book.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
addressbook = {}
print("Welcome to the Address-Book!")
while True:
# Stampo il menù che viene ristampato ogni volta che un operazione finisce
s = input(
"1. Print Address Book"
"\n2. Search"
"\n3. Add"
"\n4. Edit"
"\n5. Delete"
"\n6. Exit"
"\nInsert command: ")
if s == "1":
print(addressbook)
elif s == "2":
n = input("Who are you looking for?: ")
if n in addressbook:
print(addressbook[n])
else:
print("Name not found!")
elif s == "3":
code = input("Insert Nickname: ")
code = code.title()
if code in addressbook:
print("Contact is already present!!!")
else:
name = input("Insert name for " + code + " : ")
name = name.title()
number = input("Insert telephone-number for " + code + ": ")
addressbook[code] = ['Name: ' + name, 'Number: ' + number]
elif s == "4":
code = input("Insert Nickname to edit: ")
code = code.title()
if code in addressbook:
print("Contact found!")
name1 = input("Insert new name: ")
name1 = name1.title()
number1 = input("Insert new number: ")
addressbook[code] = "Name : " + name1, " Number: " + number1
print(code + " is update!")
else:
print("Contact not present!!!")
elif s == "5":
name = input("Insert Nickname to delete: ")
name = name.title()
if name in addressbook:
addressbook.pop(name)
print("Contact " + name + " is delete!")
else:
print("Contact not present!!!")
elif s == "6":
print("Goodbye!!!")
quit()
else:
print("Insert a valid choice!")